#Ray tracing camera local script problem

1 messages · Page 1 of 1 (latest)

snow crescent
#

I want through the local script to make my mouse cursor as a ray trace provider. So when i point and click on sth it will make an explotion

#

I want whwn the ui is on to work this only

#

the local script is located here:

sturdy perch
#

Use the mouse.Hit approach instead, since you already have access to localPlayer:GetMouse().

Replace your mouseClickConnection block with:

mouseClickConnection = UIS.InputBegan:Connect(function(inp, proc)
if proc then return end
if inp.UserInputType == Enum.UserInputType.MouseButton1 then
if uiElement.Enabled then
local targetCFrame = mouse.Hit
if targetCFrame then
local explosion = Instance.new("Explosion")
explosion.Position = targetCFrame.Position
explosion.Parent = workspace
end
end
end
end)

slim robin
#

don't do that

#

you still need help?

snow crescent
#

yes

#

@slim robin

slim robin
#

what's going wrong with your script? The mouse logic looks fine to me at least

sturdy perch
slim robin
snow crescent
#

ok

#

@slim robin

slim robin
#

can u put a few prints in there

snow crescent
#

ok let me fix it a bit

snow crescent
# slim robin can u put a few prints in there

I put some prints here but they dont work any idea?

           
-- Mouse click to create explosion
            mouseClickConnection = UIS.InputBegan:Connect(function(inp, proc)
                print('0')
                if proc then return end
                if inp.UserInputType == Enum.UserInputType.MouseButton1 then
                    print('1')
                    if uiElement.Enabled then
                        print('2')
                        local targetCFrame = mouse.Hit
                        if targetCFrame then
                            local explosion = Instance.new("Explosion")
                            explosion.Position = targetCFrame.Position
                            explosion.Parent = workspace
                            print('3')
                        end
                    end
                end
            end)
slim robin
#

none of them work?

snow crescent
#

yep

slim robin
#

is this script a module script?

#

localscript?

snow crescent
#

it is a local script

slim robin
#

hm its weird that none of them are showing up at all can u send the whole script again

#

also this says mousebutton1 not X

snow crescent
#

em ok

#

wait

graceful flareBOT
#

studio** You are now Level 5! **studio

snow crescent
#

is there a possibility because the screen gui is open the click dosnt work?