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

PlayerCount CanCollide Script Failure, why?

Asked by
BryanFehr 133
5 years ago

Hello all! I am creating a script where the parent of the scripts cancollide becomes turned off if my ScreenGui's Text is greater than 1. Why won't this script work, with no error statements? It's in a ServerScript in the Part.

local countgui = game.StarterGui.PlayerCount
if game.StarterGui.PlayerCount.Frame.TextLabel.Value >1 then
script.Parent.CanCollide = false
end
0
TextLabels don't have a Value property. DeceptiveCaster 3761 — 5y
1
You can do "if tonumber(TextLabel.Text) > 1 then". DeceptiveCaster 3761 — 5y
0
What should I do to the script then? Can you put it as an answer so I understand where I am wrong? As if the code below won't function, I can't see how yours does. @MCAndRobloxUnited BryanFehr 133 — 5y

1 answer

Log in to vote
-1
Answered by
sheepposu 561 Moderation Voter
5 years ago

Put it in a local script in the players starter gui and another local script in the part. I'm not sure the starter gui folder will target a specific player's gui. Also a player's gui folder can't be edited or viewed from outside the folder unless made from outside the folder.

Local Script in the StarterGui

local text = tonumber(script.Parent.PlayerCount.Frame.TextLabel.Text)
local bool = Instance.new('BoolValue', script.Parent.Parent)
bool.Name = 'GuiBool'
while text <= 1 do
    wait() --So the system doesn't crash
    if text > 1 then
        bool.Value = True
    end
end

Local Script inside the part

game.Players.PlayerAdded:Connect(function(plr)
    script.Parent.Touched:Connect(function(hit)
        if hit.Parent == plr.Name then
            if plr.GuiBool.Value == True then
                script.Parent.CanCollide = False
            end
        end
    end)
end)

Haven't tested it yet so hope it works

0
No, it will not. You have to do it from the PlayerGui. DeceptiveCaster 3761 — 5y
Ad

Answer this question