Infinite yield on Character

Why is this happening? I dont know it can’t find the players character

game.ReplicatedStorage.Events.Sell.OnServerEvent:Connect(function(player, Coins)
	player.Data.Coins.Value += Coins
	player:WaitForChild("Character"):FindFirstChildOfClass("Model"):Destroy()
end)

I’d say you don’t need the whole WaitForChild("Character"). The thing is, when that remote event is fired, the player’s character is most likely already fully loaded, so just use player.Character since the player himself gets passed through the remote event.

Thanks for helping

1 Like

I also want to point out that, :WaitForChild() waits for the child of the instance. “Character” is not a child of the player, it’s a property.

2 Likes

Just to add on even though this is solved, if you ever do have to wait the proper code is:

local character = player.Character or player.CharacterAdded:Wait()