I made a regeneration script but when I use it once it breaks here is the script:
function ontouched(humanoid)
object = script.Parent
if (object ~= nil) and (object ~= game.Workspace) then
model = object
messageText = "Regenerating Ship - Wait for button to respawn"
message = Instance.new("Message")
message.Text = messageText
backup = model:clone()
waitTime = 16
wait(math.random(0, waitTime))
wait(waitTime)
message.Parent = game.Workspace
model:remove()
wait(3)
model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
message.Parent = nil
end
end
game.Workspace.Explody.Touched:Connect(ontouched)
Thanks.
korbykobs
(korbykob)
April 10, 2022, 6:40pm
#2
Define “breaks”
character limit
The regen script works just fine for the first time I touch a button to explode it but then does not work or do anything when I touch it for a second time.
Ozxeb
(Ozxeb)
April 10, 2022, 7:02pm
#4
Does it print any errors? Can you confirm the script is running through the entire ontouched function?
I have a button that explodes the model but I get an error which says "Position is not a valid member of Script “Workspace.smallship.SmallshipRegenScript”
a19_9
(Nol)
April 10, 2022, 7:34pm
#6
you sure you wrote the script? it took me 1 search in the toolbox to find it and it looks very old as it uses :remove() and makejoints()
anyways making a regen script isnt that hard, simply clone the ship from replicated storage and parent it to workspace every few seconds or when the last ship is destroyed
Ozxeb
(Ozxeb)
April 10, 2022, 7:41pm
#7
Are you trying to set the position of a script? The error might be somewhere else in the script breaking the code.
Did you search the entire script or just write “regeneration script”?
I made my own regen script it only works once it activates when the player steps on a part here is the code:
local button = game.Workspace.Explody2
local Brigatine = game.Workspace.Brigatine
local copy = game.ReplicatedStorage.Brigatine:Clone()
button.Touched:Connect(function()
local ex = Instance.new("Explosion")
ex.Parent = game.Workspace
ex.Position = ex.Position + Vector3.new(106, 3.5, 8)
ex.BlastPressure = 100
ex.BlastRadius = 70
button.CanCollide = false
button.Transparency = 1
wait(16)
game.Workspace.Brigatine:Destroy()
wait(2)
copy.Parent = game.Workspace
button.CanCollide = true
button.Transparency = 0
end)
thanks
uj_9
(QXE)
April 11, 2022, 9:27am
#12
Make sure the position you wrote is correct, also models cannot take position.
a19_9
(Nol)
April 11, 2022, 5:57pm
#13
use MoveTo() instead of changing position also use debounce
1 Like