|
| 05 May 2013 10:22 PM |
local db = true local car = script.Parent.Parent
script.Parent.TouchEnded:connect(function(hit) local p = hit.Parent:findFirstChild("Humanoid") local checkplayer = hit.Parent if db then db = false if p then if car:findFirstChild(checkplayer) then hit.Parent.Parent = Workspace print("This is not "..hit.Parent.Name.."'s car!") wait(1) end end db = true end end) I made this script to set the player's parent to the Workspace when he/she jumps out of a vehicle seat. However, nothing happened when I went to test it. Help? |
|
|
| Report Abuse |
|
|
| |
|
|
| 06 May 2013 10:34 PM |
You're doing all this for a vehicle seat? When you enter a vehicle seat, a "Weld" is added. Instead of touch, why not use "ChildAdded" and "ChildRemoved"?
EX:
--Put this script into your vehicle seat
Seat = script.Parent
Seat.ChildAdded:connect(function(child) if child.ClassName == "Weld" then print ("A weld as been added. Someone is sitting in the seat") print (""..child.Part1.Parent.Name.." is sitting in the seat") end end)
Seat.ChildRemoved:connect(function(child) if child.ClassName == "Weld" then print ("A weld has been removed from the seat") print ("The seat is now available") end end)
--I think this will work. Not tested. |
|
|
| Report Abuse |
|
|
|
| 06 May 2013 10:41 PM |
Just a little addition that may make it simpler or easier to understand. Credit to Kyle.
Seat = script.Parent
function Seated(char) print(char.Name..' has sat down.'); end
function UnSeated(char) print(char.Name..' has got up.'); end
Seat.ChildAdded:connect(function(child) if child.ClassName == "Weld" then Seated(child.Part1.Parent); end end)
Seat.ChildRemoved:connect(function(child) if child.ClassName == "Weld" then UnSeated(child.Part1.Parent); end end) |
|
|
| Report Abuse |
|
|