How can I make this touched function work in normal servers? There are two simple scripts: One script is located in ServerScriptService which creates the falling parts, and it inserts the second script into each part. The second script is located in ServerStorage, and it has a simple onTouched function:
script.Parent.Touched:connect(function(hit) if hit.Anchored then script.Parent.Anchored = true script.Parent.RotVelocity = Vector3.new(0, 0, 0) script:Destroy() end end)
All the scripts function great when I play in Roblox Studio. Here is a GIF showing how it is suppose to work: http://www.giphy.com/gifs/3oz8xXd07rTffQokEw However, when I play in a server, some parts anchor mid air, and sometimes the touched script does not change the RotVelocity to (0, 0, 0). Here is another GIF illustrating how messed up the game is: http://www.giphy.com/gifs/l0HluLPMclF5GTOOk Why is this happening? Is there a way to make it work like when I play in Roblox Studio? Thank you for reading this!
I believe you get this problem because your parts gets anchored whenever anything hits them.
To fix this, you need to check if the object the part is hitting is the BasePlate.
To do this, you simply have to do this:
script.Parent.Touched:connect(function(hit) if hit.Anchored then if hit.Name == "Baseplate" then --Checks if the part hits BasePlate script.Parent.Anchored = true script.Parent.RotVelocity = Vector3.new(0, 0, 0) script:Destroy() end end end)
If this helped you, make sure you accept the answer!