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)
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