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

What is wrong with this script?


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

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

3 comments

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

0

could you place it back in the script? I have a hard time seeing what you are trying to say

0

You don't need a capital in findfirstchild, it's perfectly fine as it it.

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

1 comment

0

You don't need a capital in findfirstchild, it's perfectly fine as it it.

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