Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can Somebody help me? Please anyone, Pleeeaaassseee D;

Can somebody help me? I'm trying to figure out where I can check to see if there is a robloxian in my cars! I don't want my cars being respawned while someone sits in them, but I still want them to respawn if someone isn't in them! Help! :(

local RespawnCarsBlock=game.Workspace.RespawnCarsBlock
local Car=game.ServerStorage.Car

function RespawnCars()
print ("R3sp@wN c@rz n0w pl0x.")
for _,object in pairs (game.Workspace:GetChildren())do

if object.Name=="Car"
then 
print ("IT'S A CAR! KILL THE INFERIOR BEING!")
object:Destroy()
end
end
for _, object in pairs (game.ServerStorage:GetChildren())do

local CarCopy= object:Clone()
CarCopy.Parent=game.Workspace
CarCopy:MakeJoints()
end





end



RespawnCarsBlock.Touched:connect(RespawnCars)

2 comments

2

VehicleSeats have a property called Occupant. Just check if that's nil. http://wiki.roblox.com/index.php?title=API:Class/VehicleSeat/Occupant

1

That is a very hard script to read... try using an 'if' statement

1 answer

✓ Accepted answer

ROBLOX players can be found inside of cars, and to check them you can use the simple magnitude magic trick!


local carpart = workspace.CARMODEL.PARTNAME
local plr = game.Players.PLAYERNAME
local char = plr.Character.Torso

if (carpart.Position - char.Position).magnitude < 3 then
print("Boop")
else
return
end

1 comment

1

I would have used < 4 but wutever.

This discussion is preserved as it was. New answers, comments, and votes are closed.