I have created a script that respawns objects when a player respawns;
local player = game.Players.LocalPlayer
while player.Character == nil do wait() end
wait(.1)
local model = game.Workspace.Map
local newbase = game.ReplicatedStorage:WaitForChild(“Map”)
local module = require(script.Parent.RespawnModule)
local debounce = false
player.Character.Humanoid.Touched:connect(function(part)
if part.Name == “fakedeath” and not debounce then
debounce = true
module.Respawn(model, newbase)
wait(1)
debounce = false
end
end)
– Module Script -
local module = {}
function module.Respawn(model, newbase)
model:remove()
wait(0.7)
newbase:Clone().Parent = game.Workspace
end
return module
When the objects respawn, any scripts or values within it does not function anymore.
https://gyazo.com/a17e1124b10838aeee2538391a57b966
https://gyazo.com/e022fa7cb8fda27b6cfabe1f0f622e25
can you show us any scripts inside of the model?
Well one script is a global animation script.
local hum = script.Parent.Humanoid
local anim = hum:LoadAnimation(script.Parent.Idle)
anim:Play()
while wait(1) do
anim:Play()
end
Others just have BoolValue or IntValue
so this only works before the regeneration?
Yes. After this, the scripts and values no longer function
There must be an issue with the global script when you clone your model, did anything unusual pop up in the output when testing this? Like an error with a function for example
ha no wonder you have so many errors. so lets start one by one I will have to leave soon so I will say as much as I can, first thing you have to fix it so your script can properly find your map if it is not in Workspace then where is it? I will tell you the next thing if you have any other problems.
Map is in Workspace
Backup Map that respawns is in ReplicatedStorage
where does your map clone in what is the clone’s parent?
Map clones in the Workspace
and parented in ReplicatedStorage – The backup one.
Ok so is your script referring to the backup one or the clone? I think the backup one. That is why it is having that issue unless you are referring to the clone it is just inside another model or folder or something
1 Like
It is in the folder. I should’ve said it before
oof, ok so that so fix that and then tell me any other problems that occur sadly I have to go, but I will come back to you as soon as possible
Alright. Thank you very much (I’m typing to max the word count)