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

What is wrong with this script?

Asked by 8 years ago

location = script.Parent.Parent.Parent regen = script.Parent.Parent save = regen:clone() function onClicked() back = save:clone() wait(1) back.Parent = location back:MakeJoints() end wait(15) function onClicked() back = save:clone() wait(1) back.Parent = location back:MakeJoints() end function onClicked(hit) if hit.Parent.Humanoid~= nil then cash = game.Players:findFirstChild(hit.Parent.Name).leaderstats.Cash -- Find out who touched. if cash.Value >= 100 then cash.Value = cash.Value- 100 end end end script.Parent.Touched:connect(onClicked)

The script is to make a car respawn, but cost money if you click the button to respawn it again. Respawn works, but remove cash does not. Any suggestions?

2 answers

Log in to vote
-2
Answered by 8 years ago

Some things you could try are :FindFirstChild() capital find another thing could be your stats are typed incorrectly.

0
cash.Value = cash.Value - 100 and cash.Value = cash.Value- 100 both work. So does cash.Value = cash.Value-100 and cash.Value = cash.Value -100 MrLonely1221 701 — 8y
0
could you place it back in the script? I have a hard time seeing what you are trying to say hurricanedog 0 — 8y
0
You don't need a capital in findfirstchild, it's perfectly fine as it it. NinjoOnline 1146 — 8y
Ad
Log in to vote
-2
Answered by 8 years ago
location = script.Parent.Parent.Parent
regen = script.Parent.Parent
save = regen:clone()

function onClicked()
    back = save:clone()
    wait(1)

    back.Parent = location
    back:MakeJoints()
end
wait(15)

function onClicked()
    back = save:clone()
    wait(1)
    back.Parent = location
    back:MakeJoints()
end

function onClicked(hit)
 if hit.Parent.Humanoid~= nil then
  cash = game.Players:FindFirstChild(hit.Parent.Name).leaderstats.Cash -- Find out who touched.
  if cash.Value >= 100 then
   cash.Value = cash.Value - 100
  end
 end
end
script.Parent.Touched:connect(onClicked)

Heres what hes telling you to do i put it in this script :findFirstChild should be :FindFirstChild

0
You don't need a capital in findfirstchild, it's perfectly fine as it it. NinjoOnline 1146 — 8y

Answer this question