Advertisement
IHackShootingGames

Car

Sep 14th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. position = script.Parent.Engine.Position -- position of the engine
  2.  
  3. -- Add CFrame to Engine
  4. local frame = Instance.new("CFrameValue")
  5. frame.Name = "OriginCFrame"
  6. frame.Value = script.Parent.Engine.CFrame
  7. frame.Parent = script.Parent
  8.  
  9. -- Get the CarGarage
  10. local object = Instance.new("ObjectValue")
  11. object.Value = script.Parent.Parent.Parent
  12.  
  13. -- Get the Seat
  14. seat = script.Parent.Seat
  15.  
  16. function onChildAdded(part)
  17. -- if the user sits in the seat
  18. if part.className == "Weld" then
  19. local torso = part.Part1
  20. if torso ~= nil then
  21. local parent = torso.Parent
  22. if parent ~= nil then
  23. -- assign the CarGarage model to the player
  24. script.Parent.Parent.Parent = parent
  25. while true do
  26. wait(2)
  27. local pos = script.Parent.Engine.Position
  28. -- once the car is far enough from original spot -
  29. -- set the Regen value - so it causes another car to regenerate
  30. if (position - pos).magnitude > 30 then
  31. if object.Value ~= nil then
  32. object.Value.Regen.Value = 1
  33. wait(.5)
  34. object.Value.Regen.Value = 0
  35. object.Value = nil
  36. end
  37. break
  38. end
  39. end
  40. while true do
  41. wait(2)
  42. if part == nil then
  43. script.Parent.Parent.Parent = game.Workspace
  44. script.Parent.Parent:MakeJoints()
  45. break end
  46. end
  47. end
  48. end
  49. end
  50. end
  51.  
  52. -- When a player seats in the car
  53. seat.ChildAdded:connect(onChildAdded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement