1 | I 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. |
01 | local Vehicle = script.Parent.Vehicle:Clone() |
02 |
03 | for i, v in pairs (Vehicle:GetChildren()) do |
04 | if v:IsA( "Script" ) then |
05 | v.Disabled = true |
06 | end |
07 | end |
08 | local CurrentVehicle = script.Parent.Vehicle |
09 |
10 | local Regen = script.Parent.Regen |
11 | local ClickDetector = Regen.ClickDetector |
12 | local Display = Regen.Display.Label |
13 |
14 | local InUse = false |
15 | local Debounce = false |
1 | Currently, I use the old person 299 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 person 299 script if it can help. |
01 | --Edited Button Regen Script by Person299 |
02 | system = script.Parent |
03 | local c = system:GetChildren() |
04 | for i = 1 ,#c do |
05 | a = c [ i ] |
06 | if a.Name ~ = "person299" then |
07 | if a.Name ~ = "put in only 1 model" then |
08 | model = a |
09 | end |
10 | end |
11 | end |
12 | backup = model:Clone() |
13 | regen = system:findFirstChild( "put in only 1 model" ) |
14 | function checkRegen() |
15 | if regen.Value = = 1 then |
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.
01 | ClickDetector.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 |
You can't compare "and" to a string, it doesn't know what the string means.