I know the title may be a little confusing, so let me explain further.
I'm a beginner scripter, and I'm trying to practice making scripts run on the client, but in a way that it only plays for the person who activated the script.
So, what I'm trying to do now is make it so that if the player touches a red part, it destroys the blue part next to it, but ONLY for the player that touched the red part. (It appears for no one else.)
I thought all it would take to achieve this is for the LocalScript to be in StarterGui, but that's not the case. Help would be appreciated!
Here's my script right now.
--LocalScript inside StarterGui workspace.redbrick.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then --Checks if the person who hit was a player workspace.bluepart:Destroy() --Destroys the blue brick when the red brick is touched by the player end end) --(I want the blue brick to destroy only for the player that touched it)
Nevermind! I figured it out by using remote events. I made the server check for the touch, then ran the destroy code on the client.
After testing this it does work as intended, I would just add an if statement checking that the bluepart
exists but other than that it works fine. If you touch the redbrick
the bluepart
disappears but only on the clients screen, if you click on the server view the part is still there! Anything in a Local Script
that manipulates things in the workspace (Without firing a remoteEvent for the server to update that's a different thing) is only done on the client. Hope this helped!