I’m looking to find the best way of basically using the CharacterAdded event on the client. Due to how the player loads before a localscript detecting if there is a new player can start, it skips over the localplayer. Here is my code on Pastebin. Problem is, it doesn’t fire the event at all. Are there any other methods, possibly better ones?
So real quick, where are you putting the local script? I’m asking because this affects when the script is loaded.
In order of when local scripts start running:
My localscript is in PlayerGui.
So any content in the
StarterGui will only load after the character spawns, and never beforehand. You can test this by turning off the
CharacterAutoLoads property in the
Players, and the Gui won’t load when you click Play.
You can fix this by putting your script in
StarterPlayerScripts and waiting for your Guis when the event fires:
-- new code
local mainGameGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGameGuis")
local shop = mainGameGui:WaitForChild("Shop")
if PointWithinArea(character.HumanoidRootPart.Position, shopArea) then
shop.Visible = true
shop.Visible = false
Tested, works great! Thank you.