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

My script is working, but for everyone in the server rather than just one person, why?

Asked by 5 years ago
Edited 5 years ago

I've been working with this script for some time now and I can't seem to get it working for just one person. Whenever the script would run a certain part of it would appear for all people in the server rather than just one person (more specifications below the code). I believe it might have to do with the "if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then" line but i'm not quite sure edit it. Here is the script I have at this current point. Also I am quite new to scripting so if my script is quite unrefined or overall just messy and hard to understand sorry in advance.

Local Script in StarterGUI (since I want it to be for that specific person)

1.game.Workspace.ReflectanceLadder.AnchorPart.Touched:connect(function(hit)

2.if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then

3.for _, object in pairs(game.Workspace.ReflectanceLadder:GetChildren()) do

4.object.Anchored = false

5.if game.Workspace.ReflectanceLadder.AnchorPart.Anchored == false then

6.game.Workspace.ReflectanceSign.Transparency = 0

7.game.Workspace.ReflectanceSign.CanCollide = true

8.game.Workspace.ReflectanceSign.SurfaceGui.TextLabel.TextTransparency = 0

9.game.Workspace.ReflectanceSign.SurfaceGui.TextLabel.TextStrokeTransparency = 0

10.game.Workspace.ReflectanceSign2.Transparency = 0

11.game.Workspace.ReflectanceSign2.CanCollide = true

12.game.Workspace.ReflectanceSign2.SurfaceGui.TextLabel.TextTransparency = 0

13.game.Workspace.ReflectanceSign2.SurfaceGui.TextLabel.TextStrokeTransparency = 0

14.game.Workspace.ReflectanceSecretButton.Transparency = 0

15.game.StarterGui.ReflectanceSecret.Disabled = false

16.game.Workspace.ReflectanceSecretBlocker.CanCollide = false

17.end

18.end

19.end

20.end)

What's happening here is that when someone is climbing a ladder labeled as "ReflectanceLadder" and comes across a part named "AnchorPart" the person who touches it makes the whole ladder unanchor and breakdown. This part of the script works fine as the ladder doesn't break down for other people. After the ladder falls two signs and a button are meant to appear underneath the ladder labeled as "ReflectanceSign", "ReflectanceSign2" and "ReflectanceSecretButton" for the person who just went over that block and unanchored everything. The problem is that when someone would touch the block everyone could see the two signs and button at the bottom of the ladder which isn't my intention since I just want it for that specific person. If anyone has an answer to this problem I would like a solution. Thank you.

0
One tip for your code is to make sure you indent each block of a logical or conditional statement: everything between an "if" or "for" and it's respective "end" That way you can more easily see where each block is located in your code and can trace the logic more easily. TerminusEstKuldin 40 — 5y
0
Maybe there's no debounce and it's causing it to break due to network issues Sapppower 17 — 5y

Answer this question