local Car = workspace.Car local gun = game.Lighting.M60 local car = game.Lighting.Car2 while wait() do for i,v in pairs(game.Players:GetChildren()) do if (v.Character.Torso.Position-Car.Position).magnitude<=15 then if not v.Backpack:FindFirstChild(gun.Name) then if car:isA"Model" then car:clone() end end end end end
Hi, what I'm trying to do here is that, if someone has a tool, such as an M60 in his or her pack, and if they go near a object, such as a car, a new car or part will clone itself into the game. I tried to figure it out but I couldn't. Can anyone help me? Thank you for reading.
I fixed it up a bit. Not much explanation, besides the comments I put in the script.
local Car = Workspace.Car local gun = game.Lighting.M60 -- I recommend ServerStorage. A script once didn't work because I was trying to obtain something from Lighting. local car = game.Lighting.Car2 while wait() do for i,v in pairs(game.Players:GetChildren()) do if (v.Character.Torso.Position-Car.Position).magnitude <=15 then -- I'm not entirely sure you can get the position of a Model. I may be wrong. If I'm right, try to change the path to a particular part in the model if not v.Backpack:FindFirstChild(gun.Name) then if car:IsA("Model") then -- You need parentheses car:clone().Parent = Workspace -- Forgot to put it in Workspace car:MakeJoints() -- You gotta make the joints if it's a model that consists of 2 or more parts. end end end end end