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

My script is showing a GUI for all players when it should only show for one. Why does it do this?

Asked by 3 years ago
Edited 3 years ago

So here is one of my scripts:

local starblox = game.Teams["Starblox Employee"]

game.Workspace.Starblox.Working.Touched:Connect(function(player)
    if game.Players.LocalPlayer.Team == starblox then
        script.Parent.Enabled = true
        player.Shift.Value = true
        script.Parent.Paycheck.Disabled = false
    end
end)

game.Workspace.Starblox.End.Touched:Connect(function(player)
    if game.Players.LocalPlayer.Team == starblox then
        script.Parent.Enabled = false
        player.Shift.Value = false
        script.Parent.Paycheck.Disabled = true
    end
end)

game.Workspace.Starblox.End1.Touched:Connect(function(player)
    if game.Players.LocalPlayer.Team == starblox then
        script.Parent.Enabled = false
        player.Shift.Value = false
        script.Parent.Paycheck.Disabled = true
    end
end)

game.Workspace.Starblox.End2.Touched:Connect(function(player)
    if game.Players.LocalPlayer.Team == starblox then
        script.Parent.Enabled = false
        player.Shift.Value = false
        script.Parent.Paycheck.Disabled = true
    end
end)

game.Workspace.Starblox.End3.Touched:Connect(function(player)
    if game.Players.LocalPlayer.Team == starblox then
        script.Parent.Enabled = false
        player.Shift.Value = false
        script.Parent.Paycheck.Disabled = true
    end
end)

This script enables another script, which is here:

local starblox = game.Teams["Starblox Employee"]
local player = game.Players.LocalPlayer

while true do
    player.Time.Value = player.Time.Value + 1
    if player.Time.Value == 60 then
        if player.Team == starblox  then
            game.ReplicatedStorage.Paycheck:FireServer()
        end
        player.Time.Value = 0
    end
    wait(1)
end

These scripts are both localscripts. I have changed the code many different times but it still shows for all players. How do I fix this?

1 answer

Log in to vote
0
Answered by 3 years ago

The touches functions doesn't even check who touched the parts. Btw use a script (Server) to detect touches.

0
Oh yeah, I forgot that I used player and not hit. poop07393cfhi3n2222 4 — 3y
0
lol acediamondn123 147 — 3y
Ad

Answer this question