Script in ServerScriptService:
wait(5) game.Players.PlayerAdded:Connect(function() if game.Players.LocalPlayer.hasJoined.Value == false then game.Players.LocalPlayer.hasJoined.Value = true end end)
Script in LocalScript in StarterGui:
local joinedVal = game:GetService("Players").LocalPlayer.hasJoined if joinedVal.Value == false then script.Parent.MainUI.StarterPack.Visible = true elseif joinedVal.Value == true then script.Parent.MainUI.StarterPack.Visible = false end
Question: Value does not set when player joins the game.
With FilteringEnabled, the server cannot access LocalPlayer. Since FE is now enabled for all games, this is mandatory to know. This means that doing game.Players.LocalPlayer
in a Server Script will NOT work!
What can you do? Relevant to this answer, you can use the first paramater of PlayerAdded
.
Here's the updated code below:
wait(5) game.Players.PlayerAdded:Connect(function(plr) -- grabbing the plr that joined if plr.hasJoined.Value == false then -- replace LocalPlayer with our newly grabbed player plr.hasJoined.Value = true -- replace LocalPlayer with our newly grabbed player end end)
If you're not using PlayerAdded
, you can use RemoteEvents and the likes in order to grab the player.