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

When model is cloned from replicated storage, it breaks script?

Asked by 4 years ago

I'm having a very weird problem and it might actually be unsolvable. So in the game i am making, you respawn your car from replicated storage into the workspace. heres the code for that:

local clone = game.ReplicatedStorage.car
backup = clone:Clone() 
function click()
    script.Parent.Visible = false
    clone=backup:clone()
    clone.Parent=game.Workspace
    clone:makeJoints()
    wait(30)
    script.Parent.Text="Spawn Car"
    script.Parent.Visible = true   

end    

script.Parent.MouseButton1Click:Connect(click)

I also have an upgrade system which upgrades the power in the cars. The only problem is that when the car is cloned from replicated storage, the upgrade code doesn't work. However, if i put the car into the workspace to start out with, it does.

heres the code for the upgrade system:

local pad = script.Parent.Parent.Parent.Pad
local debounce = false

while true do
    if not debounce then
        debounce = true
        function padTouched(part)
            if part.Name == "Wheel" then
                local h = part.Parent
                if (h ~= nil)and h.VehicleSeat.EngineSize ~= "2.8" then
                    h.VehicleSeat.EngineSize.Value = "2.8"
                    h.VehicleSeat.MaxSpeedFinal.Value = h.VehicleSeat.MaxSpeedFinal.Value + 40
                    h.EngineBadge.SurfaceGui.TextLabel.Text = "2.8L RACE L4"
                    print "upgrade sucsessful!"
                    wait(1)
                    debounce = false
                end
            end
        end
        pad.Touched:Connect(padTouched)
    end
    wait(0.1)
end

Its very weird.

0
First of all, you don't need to add a new pad.Touched event every tenth of a seconds. You can do it just once, and will work forever until the object is destroyed or you manually disconnect. Yuuwa0519 197 — 4y
0
i did that, it didnt help the problem LemaFoxtrot 14 — 4y
0
this probably won't solve it, but you cloned that car 2 times 0msh 333 — 4y

Answer this question