Click to respawn cart script

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

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)

move to #help-and-feedback:code-review

Scripting support is meant for getting help with scripts, like fixing errors etc.

1 Like