How to make player keep a item after death

  1. What do you want to achieve? Make a player keep an item after death

  2. What is the issue? I don’t know how to do that

  3. What solutions have you tried so far? I tried looking it up but nothing worked

I hope someone can help!

4 Likes

just type in

tool.parent = player:WaitForChild("StarterGear")

replace tool with the tool location or tool name.

Some people are new to Roblox Studio so they don’t know the use of the properties. Like me when i was new, lets don’t get too hard for new users. we must help and support them.

Well no (sadly) because the output says this:

parent is not a valid member of Tool 

where is the tool located, how does your script work??? From there I can help you and guide you through.

Parent with a capital P and not p

It is located in ReplicatedStorage and the item is given to the player when they buy it.

oh ok. So then locate the tool and replace it with tool. The tool I wrote is just a placeholder.

If its still not working, would you mind sharing me the whole script?

It still returns the same error

Here is the code:

local sword = game.ReplicatedStorage.Sword
local player = game.Players.LocalPlayer
local player = game.Players.LocalPlayer
local label = script.Parent.Parent.Parent.Parent.NotEnought
local coinsNeeded = 500

local leaderstats = game.Players.LocalPlayer:WaitForChild("leaderstats")
local stat = leaderstats:WaitForChild("RC") 


script.Parent.MouseButton1Click:Connect(function()
	
	if stat.Value > coinsNeeded then
		stat.Value -= coinsNeeded
		
		sword:Clone().parent = player:WaitForChild("StarterGear")
		
	else
		label.Text = "Not enough money!"
		label.Visible = true
		wait(2.5)
		label.Visible = false
	end
	
	
end)

Its sword:Clone().Parent = player:WaitForChild("StarterGear")

With an capital P!!!

You should use an event instead of giving a tool through client because when it made action to client, it won’t be visible to the server/ other users.

• Create a event in ReplicatedStorage

Client

local label = script.Parent.Parent.Parent.Parent.NotEnought
local coinsNeeded = 500
button.Activated:Connect(function()
if stat.Value > coinsNeedee then
game:GetService("ReplicatedService").Event:FireServer()
else
label.Text = "Not enough money!"
		label.Visible = true
		wait(2.5)
		label.Visible = false
end
end)

Server

local sword = game.ReplicatedStorage.Sword
local coinsNeeded = 500
game:GetService("ReplicatedService").Event.OnServerEvent:Connect(function(player()
		stat.Value -= coinsNeeded
		
local Newsword = sword:Clone()
		Newsword.parent = player:WaitForChild("Backpack")
end)
1 Like
local sword = game.ReplicatedStorage.Sword
local player = game.Players.LocalPlayer
local label = script.Parent.Parent.Parent.Parent.NotEnought
local coinsNeeded = 500

local leaderstats = game.Players.LocalPlayer:WaitForChild("leaderstats")
local stat = leaderstats:WaitForChild("RC") 


script.Parent.MouseButton1Click:Connect(function()
	
	if stat.Value > coinsNeeded then
		stat.Value -= coinsNeeded
		
		sword:Clone().Parent = player:WaitForChild("StarterGear")
		
	else
		label.Text = "Not enough money!"
		label.Visible = true
		wait(2.5)
		label.Visible = false
	end
	
	
end)

It is indeed a capital mistake.

1 Like