Click to respawn Cart Script

This is a script inside of a part with a ClickDetector also. The script works I’m just wondering if I am able to make this script a bit smaller or better.

Script:

local a = script.Parent.Parent.Cart:clone()
local deb = false

function chng()
if deb == true then return end
deb = true
local new = a:clone()
new.Parent = script.Parent.Parent
new:MakeJoints()
script.Parent.BrickColor = BrickColor.new(21)
wait(6)
script.Parent.BrickColor = BrickColor.new(28)
deb = false
end

script.Parent.Click.MouseClick:connect(chng)
1 Like

Task.wait.

connect should be Connect.

uppercase.

1 Like

Do I make the “a” an uppercase?

I meant the "c"lone should be uppercase.

1 Like

Oh, alright.

Everything should look like this, correct?

local a = script.Parent.Parent.Cart:Clone()
local deb = false

function chng()
if deb == true then return end
deb = true
local new = a:clone()
new.Parent = script.Parent.Parent
new:MakeJoints()
script.Parent.BrickColor = BrickColor.new(21)
task.wait(6)
script.Parent.BrickColor = BrickColor.new(28)
deb = false
end

script.Parent.Click.MouseClick:Connect(chng)
1 Like

Exactly.

You might wanna go grammarly here.

I’m not a scripter I follow a tutorial to make this script. What in “local new = a:clone()” do I make Grammarly?

local new = a:Clone()

Btw gl in ur script journey

1 Like

Thank you for helping me fix everything :slight_smile:

1 Like