Is there anything else you need?
Read the title please, i edited like 1 hour ago.
Yeah, u asked for it to when the Player respawns, As I showed.
I updated so I am sure it won’t. btw this should be in StarterCharacterScripts.
Umm, i don’t know what you say about but it even worked on StarterPlayerScripts.
Yeah but it would work once in StarterPlayerScripts. In StarterCharacterScripts it will always work.
It worked twice for me (I guess for StarterPlayerScripts and StarterCharacterScripts, it will always work).
What’s the Problem currently? I’m confused.
You asked a Script when the Player dies and respawns?
No, it’s not that, it’s when the Part is on Replicated and when the Character (Player)
dies, the Part is on Workspace but when you died you can’t collect the Part to get money just to help @PuffyJasonrocks84.
Hello!
If you want a part from ReplicatedStorage to “spawn” in your Workspace you could simply clone it and parent it to the Workspace as it follows:
local ReplicatedStorage = game:GetService("Replicated Storage")
local part = ReplicatedStorage:WaitForChild("yourPart")
part:Clone()
part.Parent = game.Workspace
It’s actually called Part so you can do this:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local part = ReplicatedStorage:WaitForChild("Part")
part:Clone()
part.Parent = game.Workspace
Sure, you could make it spawn After the Player respawns with the script I’ve given you Just save the Position of the HRP and Clone it to workspace and set it to the Position of HRP
I get this error:
leaderstats is not a valid member of Players “Players” - Client - LocalScript:10
--// Settings \\--
local player = game.Players
local Data = game:GetService("DataStoreService"):GetDataStore("TheRandomData")
--// Script \\--
game.Players.PlayerAdded:Connect(function(player)
--// Creating the folder \\--
local folder = Instance.new("Folder", player)
folder.Name = "leaderstats"
--// Creating the Currency \\--
local Money = Instance.new("NumberValue", folder)
Money.Value = 1000
Money.Name = "Money"
local dataload = Data:GetAsync(tostring(player.UserId))
if dataload then
Money.Value = dataload[1]
end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local CanBePickedUp debounce = false
local CashToRemove = -50
local CashToGive = 50
Character:WaitForChild("Humanoid").Died:Once(function()
game.Players.leaderstats.Money.Value = CashToRemove
LowerTorso = LocalPlayer.Character.LowerTorso
Part = LowerTorso
Part.Anchored = false
Part = game.ReplicatedStorage.Part
game.ReplicatedStorage.Part:Clone().Parent = game.workspace
if Part.Anchored == false then
Part.Touched:Connect(function()
Players.leaderstats.Money.Value = CashToGive
Part:Destroy()
end)
end
end)
I get the error out of nowhere even though the leaderstats is in the Player.
Change the variable called player to something else and it should be ok
Nevermind i found it:
ReplicatedStorage = game:GetService("ReplicatedStorage")
Players = game:GetService("Players")
LocalPlayer = Players.LocalPlayer
Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
debounce = false
CashToGiveButYouRemove = 50
Part = ReplicatedStorage.Part
Character:WaitForChild("Humanoid").Died:Once(function()
Players.LocalPlayer.leaderstats.Money.Value -= CashToGiveButYouRemove
LowerTorso = Part
Part = ReplicatedStorage.Part
Part = LowerTorso.CFrame
game.ReplicatedStorage.Part:Clone().Parent = game.workspace
end)
But this doesn’t give money, it just removes it.
local CashToGive = 50
local Players = game.Players
local Part = script.Parent
Part.Touched:Connect(function(hit)
Players.LocalPlayer.leaderstats.Money.Value += CashToGive -- The issue's here.
Part:Destroy()
end)
So when you touch the part you lose 50 money?
No, it’s when you die, precisely.
Use the humanoid.Died:Function()
to do that
Thats because you have this
Character:WaitForChild("Humanoid").Died:Once(function()
Players.LocalPlayer.leaderstats.Money.Value -= CashToGiveButYouRemove
LowerTorso = Part
Part = ReplicatedStorage.Part
Part = LowerTorso.CFrame
game.ReplicatedStorage.Part:Clone().Parent = game.workspace
end)
I removed it.
This text will be blurred.