Cart Ride Game Help

I’m trying to create a cart ride game, and everything is working as it’s intended to except that when I try to spawn the cart more than one time it doesn’t and it doesn’t give me any errors.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")

local NewCart = ReplicatedStorage:FindFirstChild("Cart"):clone()

local Button = script.Parent.Parent
local ClickDetector = script.Parent

local PositionInformation = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	true,
	0
)
local ColorChangeInformation = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)
local ColorChange1Goal = 
	{
		Color = Color3.new(0.768627, 0.156863, 0.109804)
	}
local ColorChange2Goal = 
	{
		Color = Color3.new(0.294118, 0.592157, 0.294118)
	}
local PositionChangeGoal = 
	{
		Position = Vector3.new(Button.Position.X, Button.Position.Y - 0.0625, Button.Position.Z)
	}
local ColorChange1Tween = TweenService:Create(Button, ColorChangeInformation, ColorChange1Goal)
local ColorChange2Tween = TweenService:Create(Button, ColorChangeInformation, ColorChange2Goal)
local PositionChangeTween = TweenService:Create(Button, PositionInformation, PositionChangeGoal)

local deb = false

ClickDetector.MouseClick:Connect(function(Player)
	if deb == false then
		deb = true
		ColorChange1Tween:Play()
		PositionChangeTween:Play()
		wait(0.5)
		NewCart.Parent = Workspace
		NewCart:MakeJoints()
		NewCart:FindFirstChild("Owner").Value = Player.Name
		wait(2.5)
		ColorChange2Tween:Play()
		deb = false
	end
end)

Any help will be appreciated!

local NewCart = ReplicatedStorage:FindFirstChild("Cart"):clone()

--- function
		NewCart.Parent = Workspace

I think you have to Clone NewCart inside the ClickDetector function instead of at the top of your script. Otherwise it gets cloned once & placed, but the next time you click you aren’t cloning it again.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.