Run a CharacterAdded or something similar inside of a localscript?

Hey! I am making an emote shop system and have ran into a trouble I can’t seem to find a fix for online. I need to check the emotes status (as in if it’s owned or not my the player) and need to run a function every time the player spawns problem is, I can’t seem to get a CharacterAdded function to work, nor any other substitutes I’ve tried (like workspace.ChildAdded). I would really really appreciate some help with this, thanks.

local price = 100
local player = game.Players.LocalPlayer
local char = player.Character
local inv = player:WaitForChild("EmoteInventory")
local equipInv = player:WaitForChild("EquippedEmote")
local button = script.Parent
local ls = player:WaitForChild("leaderstats")
local goins = ls:WaitForChild("Goins")
local emote = game.ReplicatedStorage.Emotes.TestEmote.Emote
status = "nil"

local function recheck()
	if emote.Parent == inv then

		button.Text = "EQUIP"
		status = "owned"

	end

	if emote.Parent == equipInv then

		button.Text = "UNEQUIP"
		status = "equipped"

	end

	if emote.Parent == game.ReplicatedStorage.Emotes.TestEmote then

		button.Text = "PURCHASE"
		status = "unowned"

	end
end

player.CharacterAdded:Connect(function()

	recheck()

end)

button.Activated:Connect(function()
	if status == "unowned" then
		print("DOne")
		if goins.Value >= 100 then
			goins.Value = goins.Value - 100
			emote.Parent = inv
			status = "owned"
			recheck()
		end
		
	end
	
end)
1 Like

LocalPlayer only works in LocalScript.
Then, I assume button is in Player’s GUI.

And, replace variable “status” to other thing.

Maybe you are stealing emote.

This is a local script. Is there any way for this to work in localscript?