Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

PlayerCount CanCollide Script Failure, why?

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

3 comments

0

TextLabels don't have a Value property.

1

You can do "if tonumber(TextLabel.Text) > 1 then".

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

1 answer

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

1 comment

0

No, it will not. You have to do it from the PlayerGui.

This discussion is preserved as it was. New answers, comments, and votes are closed.