Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- position = script.Parent.Engine.Position -- position of the engine
- -- Add CFrame to Engine
- local frame = Instance.new("CFrameValue")
- frame.Name = "OriginCFrame"
- frame.Value = script.Parent.Engine.CFrame
- frame.Parent = script.Parent
- -- Get the CarGarage
- local object = Instance.new("ObjectValue")
- object.Value = script.Parent.Parent.Parent
- -- Get the Seat
- seat = script.Parent.Seat
- function onChildAdded(part)
- -- if the user sits in the seat
- if part.className == "Weld" then
- local torso = part.Part1
- if torso ~= nil then
- local parent = torso.Parent
- if parent ~= nil then
- -- assign the CarGarage model to the player
- script.Parent.Parent.Parent = parent
- while true do
- wait(2)
- local pos = script.Parent.Engine.Position
- -- once the car is far enough from original spot -
- -- set the Regen value - so it causes another car to regenerate
- if (position - pos).magnitude > 30 then
- if object.Value ~= nil then
- object.Value.Regen.Value = 1
- wait(.5)
- object.Value.Regen.Value = 0
- object.Value = nil
- end
- break
- end
- end
- while true do
- wait(2)
- if part == nil then
- script.Parent.Parent.Parent = game.Workspace
- script.Parent.Parent:MakeJoints()
- break end
- end
- end
- end
- end
- end
- -- When a player seats in the car
- seat.ChildAdded:connect(onChildAdded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement