So, my friend wanted to script his game and wanted me to make a script which clones a boombox from ServerStorage to player.Backpack on the server, this is my code. I have a remote function in Replicated Storage called "Owner Give"
game.ReplicatedStorage["Owner Give"].OnServerEvent:Connect(function(player)
local ServerStorage = game:GetService("ServerStorage")
if player.Name == "Waffleszx" then
ServerStorage["Owner Boom"]:Clone().Parent = player.Backpack
end
-----------
if player.Name == "3ora" then
ServerStorage["Owner Boom"]:Clone().Parent = player.Backpack
end
-----------
if player.Name == "Ghxsst" then
ServerStorage["Owner Boom"]:Clone().Parent = player.Backpack
end
----------
if player.Name == "TUNDRAMANE" then
ServerStorage["Owner Boom"]:Clone().Parent = player.Backpack
end
----------
wait(0.1) -- this is the part where im struggling, how do i make this run every time player dies?
if player.Backpack:FindFirstChild("Owner Boom") then
player.Parent.Parent.Workspace[player.Name].Humanoid.Died:Connect(function()
wait(5.7)
ServerStorage["Owner Boom"]:Clone().Parent = player.Backpack
end)
end
end)
I also have my LocalScript which is firing the remote in ReplicatedFirst.
wait(1)
game.ReplicatedStorage["Owner Give"]:FireServer()

10 comments
Why do you need the RemoteFunction? Note that a RemoteFunction is used to get a response back from where you're communicating to, this case from the server.
Because the tool breaks if I don't use the remote event.
Also, it's a remote event not a remote function..
Quick question as im going through this, the second part pertaining to the humanoid death is supposed to occur for all players or just the 4 owners?
Also note that I have tried using a loop, it just spams me with lots of boomboxes. There is probably another method to use looping but i'm not too skilled at scripting.
The player argument gets the player who is running the script (player who joined the game), so it's supposed to occur for the player who has just joined.
the LocalScript is in ReplicatedFirst, so it runs when the player joins the game to check if their username is any of those 4.
i understand that, im wondering if only the four specified people are supposed to get a boombox or whatev
Yes, only the four specified people are supposed to get it, but only at once since it checks for each player who joins the server
Say if me (3ora) joined the game, I would get the boombox since the name matches. If my name was "Shedletsky" the remote event would fire but do nothing since the name is not whitelisted.