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
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