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

Make a part destroy locally?

Asked by 2 years ago

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)
0
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. SanicBoy727 2 — 2y

2 answers

Log in to vote
0
Answered by 2 years ago

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.

0
I didn't see this when I uploaded my answer, sorry strangejmaster43 139 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

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!

Answer this question