Hey, I’ve been struggling with this script for a while now and thought I should finally seek some help. So I made a script where when a player dies and they have over a certain amount of items they lose one of those items and if they have an item they end up dropping it. I am using the script in serverscript services but it is not working on the part where it clones the obejct. The script itself works and when the player has above 0 and dies it does go down -1 but it does not drop the part I want it to drop.
Here is the script, it doesn’t drop the part when the player dies. I want it to do that when the player has >0. Also has to work in serverscript. I know I can do it in characterfolder but I prefer the serverscript
I tried using the PlayerAdded and CharacterAdded events once like you did, and it was supposed to print “Button was clicked”. Maybe remove the PlayerAdded and CharacterAdded events?
Normally CharacterAdded will not run the first time the character spawns, its annoying. To fix, after you do CharacterAdded, wait for the character to spawn with a loop, then you can do your died event after the character is loaded.
This is what the loop would look like
repeat
task.wait()
until player.Character ~= nil
--here you can do your Humanoid.Died event
Also, you should not be editing UI on the server, instead you should use RemoteEvents to tell the client to update UI. Never deal with PlayerGui on the server.
Minor nitpick, but instead of sending a screenshot of your code, you should copy and paste it and add 3 ` to set it as code.
This is what it looks like:
Finally, you should be using task.wait() instead of wait() as task.wait() is better in every single way.