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

What's wrong with this script?

Asked by 9 years ago
Car = game.Workspace["Nissan 240SX(Car)"]
local Clone = Car:Clone()
function OnTouched(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        for _,Player in pairs(game.Players:GetPlayers()) do
        if Player:FindFirstChild("leaderstats") then
    if Player.leaderstats.Money.Value > 68000 then do
            Player.leaderstats.Money.Value = Player.leaderstats.Money.Value -68000
            if game.Players:GetPlayerFromCharacter(script.Parent)then do
            Clone.Anchored = false
            Clone.Position = Vector3.new(-24, 9.2, -874)
            Clone.Parent = game.Workspace
            Clone.Anchored = true
            wait(2)
            Clone.Anchored = false
            end
            end
            end
            end
        end
        end
    end
end


script.Parent.Touched:connect(OnTouched)

What i'm trying to do is when you step on the button, it takes $68000 and spawns the car at its coordinates.

Mistake:

1) It doesn't spawn the copied car at its coordinates.

All help would be gladly appreciated. Thanks! (Please don't say just one word)

Edit:

Car = game.Workspace("Nissan 240SX(Car)")

function OnTouched(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        for _,Player in pairs(game.Players:GetPlayers()) do
        if Player:FindFirstChild("leaderstats") then
    if Player.leaderstats.Money.Value > 68000 then do
    Player.leaderstats.Money.Value = Player.leaderstats.Money.Value -68000

function CarRespawn(hit)
            if game.Players:GetPlayerFromCharacter(script.Parent)then
            Clone = Car:Clone()
            Clone.Anchored = false
            Clone:MoveTo(Vector3.new(-24, 9.2, -874))
            Clone.Parent = game.Workspace
            Clone.Anchored = true
            wait (2)
            Clone.Anchored = false
            end
            end
            end
            end
        end
        end
    end
end


script.Parent.Touched:connect(CarRespawn)
script.Parent.Touched:connect(OnTouched)

1 answer

Log in to vote
1
Answered by 9 years ago

Models do not have a "Position" property. You will have to use Move to.

 Clone:MoveTo(Vector3.new(-24, 9.2, -874))
0
Thanks! :) notes4u99 65 — 9y
0
Did I use it right or did I do something wrong again? Its in my Edit. notes4u99 65 — 9y
Ad

Answer this question