https://gyazo.com/f31c3c00bf22bde1b4eed2920cf2cdd0
idk what do
pls help
You’re only checking the target once.
This might be because the if condition runs only once, meaning that the player’s mouse might not be pointing at a part when it runs once. To fix that you can use a loop like a while loop to continuously detect if the mouse is pointing at a part. Or you can use Mouse.Moved function but I found that very laggy when I used it.
So, use a while loop and put the if condition inside it. Make sure you are using wait in the loop.
While true do
If condition here
Wait(0.001) < you need this!
end
mouse.Button1Down:Connect(function()
print(mouse.Target)
end)
nope doesent work
While true do
If condition here
Wait(0.001) < you need this!
end
while wait() do
is not unstable in any way. wait
will never not delay execution.
I suspect this is something similar to what you’re wanting. The issue in your original script is that you’re only checking mouse.Target
once, with this snippet, it’s checked every time you click. I’d recommend you check out the Developer Wiki article on the Mouse object and scroll down to “events”.
i want when its point at it “Target” then print The Name of it
but why its not working i did it and its not printing nothing when i click something
Is it in a LocalScript or regular Script?
its in local script i did that
can you make Example place for me?
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Baseplate = game.Workspace.Baseplate
mouse.Button1Down:Connect(function()
if mouse.Target == Baseplate then
print("The part is Baseplate")
end
end)
Hope this helps
thx now i undarstand thx you and for everyone else
yes i undarstand where is my mistake thx
There’s a very different reason why what Carbyne said is appropriate. It is somewhat unstable, but not in the sense that wait has the potential to return a non-truthy value.
Thanks for the heads up! I think in this case while wait() do
is perfectly fine, though. Could you elaborate on what you mean by unstable? I don’t see how a while wait() do
loop could “break”.