Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

How to make it when you click a car it copy's it and spawns it?

Asked by 8 years ago

``I have a bit of a script on how i thought it should work but my problem is that it wont spawn the car in after purcasing it let alone take away the money from the players leaderboard.

Can someone help, Also this is the script i used

Door = script.Parent 
local debounce = false 

function getPlayer(humanoid) 
local players = game.Players:children() 
for i = 1, #players do 
if players[i].Character.Humanoid == humanoid then return players[i] end 
end 
return nil 
end 
function onTouched(hit) 
if debounce == false then 
local human = hit.Parent:findFirstChild("Humanoid") 
if (human == nil) then return end 
local player = getPlayer(human) 
debounce = true 
if (player == nil) then return end 
local stats = player:findFirstChild("leaderstats") 
local sp = stats:findFirstChild("Cash")
if sp == nil then return false end 
if (sp.Value >=467) then 
sp.Value = sp.Value - 0 
print("Enough Money") 
local car = game.Lighting.veyron:clone()
car.Parent = game.Workspace
car:makeJoints()
Door.BrickColor = BrickColor.new(21)
wait(2) 
Door.BrickColor = BrickColor.new(37)
debounce = true
else debounce = false 
end 
end 
end 

connection = Door.Touched:connect(onTouched)

Answer this question