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

What's wrong with this script?

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

✓ Accepted answer

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

 Clone:MoveTo(Vector3.new(-24, 9.2, -874))

2 comments

0

Thanks! :)

0

Did I use it right or did I do something wrong again? Its in my Edit.

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