Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the detector detecting these parts before they even get touched?

Asked by 6 years ago
Edited 6 years ago

Here is a GIF: GIF (In the GIF the detector is the RED brick) And the code:

script.Parent.Touched:connect(function(part)
if part.Name=="Music" then
game.Workspace.Missed.Value=game.Workspace.Missed.Value+1
part:Destroy()
end
end)

All the parts are named music... so why is it detecting early?

0
It could be the difference in time between the detector signaling the event and the Roblox client updating the viewport. Try lowering the speed of the "Music" parts and see if they make it closer to the bar. KidTech101 376 — 6y
0
@KIdTech101 It still doesn't make it much clsoer Void_Frost 571 — 6y
0
If not already, you should handle this on the client side. Peyt_n 20 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I recomend you adding a "WaitForChild" event so the script will run when the child name gets touched.

Example:

script.Parent.Touched:connect(function(part) part:WaitForChild("Music") if part.Name == "Music" then game.Workspace.Missed.Value=game.Workspace.Missed.Value+1 part:Destroy() --Don't forget to remove the end without the ")" end)

That should fix your problem. BUT in case that doesn't work, try adding a "FindFirstChild" event so the script will run when the child name "Music" is found.

script.Parent.Touched:connect(function(part) part:FindFirstChild("Music") if part.Name == "Music" then game.Workspace.Missed.Value=game.Workspace.Missed.Value+1 part:Destroy() --Don't forget to remove the end without the ")" end)

That should fix your problem either.

If none of these work, then try on a local script (99% sure it won't work but worth the try, eh?)

And If that doesn't work ask someone else ;-;

Ad

Answer this question