What I mean is when I die an object will respawn where it started. I’ve seen how to do it globally, but I want it to be locally so that each player has their own objects (in the same position).
If you can give me an example that would be great. I’ve spent too much time on what I thought was going to be pretty easy.
Use a LocalScript and duplicate the specific part/model from replicatedstorage each time the player dies.
You can use Humanoid.Died
function to preform this.
More on that topic: Humanoid.Died
Yeah, I tried that but it dident be seemed to be working. Maybe I was putting it together wrong. Oh, I think I know what I did wrong
Please send me your current code.
Wait I’m supposed to use a local script don’t I. I’m tired, I need sleep. Ok I switched it to a local script. (If I don’t respond I might be asleep, mb)
What’s the script’s location? Scripts will only execute when placed inside specific containers (those containers depend on the script’s type).
The script in the image is located in server script service
youre actually cloning the Box only once so everytime the character dies you parent the same box to workspace, put “local Box = game.ReplicatedStorage.box:Clone()” after the Died function
So what your saying is if I put the local variable in there it will create a new box each time? That makes sense actually.
Try creating a clone of the object every time the character spawns (player.characteradded) and setting the cframe to the same as the original’s cframe then deleting the orignal and setting the orignal to the clone
(Only set the cframe if you want it to be in the same place)
wait(0.1) -- make sure its loaded
game.Players.PlayerAdded:Connect(function(p)
if game.Players.LocalPlayer then --checks if this is local or not
if p.Name ~= game.Players.LocalPlayer.Name then
return
end
end
local org = nil
p.CharacterAdded:Connect(function(char)
local objToClone = game.ServerStorage.Object --put your object here
if not objToClone then
warn("couldnt find object to clone, player: "..p.Name)
return
end
local clone = objToClone:Clone()
if org then
org:Destroy()
end
org = clone
clone.Parent = game.Workspace
end)
end)
Note please dont keep the original object in workspace put in replicated storage or serverstorage
You can also put this in a local script in a screen gui that has reset on spawn off (in startergui)
If it doesnt work on a local script i am sorry
What do you mean has reset on and spawn off?
that worked but only globally, why won’t it work locally?
If you want to put it in a Local Script, there’s only a few places you can put it as a descendant in for it to work. You should check this link in order to see all of those descendant types: LocalScript
in a screen gui you can simply just tick “reset on spawn” and put that local script in and make sure the screen guis parent is under starter gui, but i can make it local if you want if that doesnt work
Yeah, that would be great, but I can’t get it to work in just a normal script.
I tried all of those but none of them seem to work maybe because the died functions only works through the server, I don’t know.
What does your code currently look like? Could you send an image?