So, im trying to make it so a button on my death screen costs robux and saves your items once you respawn. Here’s my script for now.
game.ReplicatedStorage.RespawnRE.OnServerEvent:Connect(function(plrFired)
plrFired:LoadCharacter()
end)
So, im trying to make it so a button on my death screen costs robux and saves your items once you respawn. Here’s my script for now.
game.ReplicatedStorage.RespawnRE.OnServerEvent:Connect(function(plrFired)
plrFired:LoadCharacter()
end)
you probably need to return some values in the remoteevent, like a table containing all of the tools they had, so you can give them back to you
i would do something like
local ReplicatedStorage = game:GetSerivce("ReplicatedStorage")
local MainEvent = ReplicatedStorage:FindFirstChild("MainEvent")
MainEvent.OnServerEvent:Connet(function(plrFired: Player, Subject: string, ...: any)
if not Player then
return -- returns if player is not spawned
end
local Argument = {...} -- sets the arguments into table
if Subject == "RespawnDeathProduct" then
local Items = Argument[1] -- this is where the tools/items is basically the backpack
local ItemstoSave = {]
table.insert(ItemsToSave, Items) --- inserts the items in the table
plrFired:LoadCharacter() --- loads the character
task.spawn(function()
for i, v in pairs (ItemstoSave) do -- checks for the tools
if v ~= nil and v:IsA("Tool") then
v.Parent = plrFired.Backpack -- redirects the items into the players backpack
end
end
ItemstoSave = {} -- resets the table once the player respawned
end)
end
end)
sorry for the late reply, i had this in my drafts and never finished it. i’m pretty sure what happened was that it made the button come up with prompt and when you buy it, nothing happened.