Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Regen Dilemma, can it be fixed?

Asked by 10 years ago
1I have a new vehicle regen that is designed  not to regen the vehicle if the vehicle is in use. However, when the vehicle is legitimately regenned the vehicle disintegrates to its most basic parts. How can I fix this so the vehicle can be regenned to its original structure rather than fall apart? Here is a copy of the regen script.
01local Vehicle = script.Parent.Vehicle:Clone()
02 
03for i, v in pairs(Vehicle:GetChildren()) do
04    if v:IsA("Script") then
05        v.Disabled = true
06    end
07end
08local CurrentVehicle = script.Parent.Vehicle
09 
10local Regen = script.Parent.Regen
11local ClickDetector = Regen.ClickDetector
12local Display = Regen.Display.Label
13 
14local InUse = false
15local Debounce = false
View all 82 lines...
1Currently, I use the old person299 regen. Besides the fact that the vehicle can be regened right out from under you, the regen works great. Here is a copy of the person299 script if it can help.
01--Edited Button Regen Script by Person299
02system = script.Parent
03local = system:GetChildren()
04for i = 1,#c do
05a = c[i]
06if a.Name ~= "person299" then
07if a.Name ~= "put in only 1 model" then
08model = a
09end
10end
11end
12backup = model:Clone()
13regen = system:findFirstChild("put in only 1 model")
14function checkRegen()
15if regen.Value == 1 then
View all 25 lines...

2 answers

Log in to vote
1
Answered by
Redbullusa 1580 Moderation Voter
10 years ago

The joints for the vehicle is not connecting when regened.

To make it connect, use the :MakeJoints() method (as shown on Person299's script on line 22) on your model.

01ClickDetector.MouseClick:connect(function()
02    if not InUse and not Debounce then
03        Debounce = true
04        UpdateUse()
05        CurrentVehicle:Destroy()
06        CurrentVehicle = Vehicle:Clone()
07        CurrentVehicle.Parent = Workspace
08    CurrentVehicle:MakeJoints()             -- CurrentVehicle connects its joints at this point
09        for i, v in pairs(CurrentVehicle:GetChildren()) do
10            if v:IsA("Script") then
11                Delay(0.1, function()
12                    v.Disabled = false
13                end)
14            end
15        end
View all 21 lines...
0
Thank you Redbullusa, It works! In my small scale tests it functions just as well as Person299, time to implement it full scale! I’m also a little annoying because I was so close to fixing it myself. Before I posted this help request I made the very same modification but on line 69 as opposed to line 70 :S RobloxBossk 20 — 10y
0
You're very welcome. C: Redbullusa 1580 — 10y
Ad
Log in to vote
1
Answered by
Irvene 5
10 years ago

You can't compare "and" to a string, it doesn't know what the string means.

Answer this question