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

If my value is bigger than 0 then it's gonna run it. But it's not doing it why??

My local script:

--local remote = game.ReplicatedStorage.RemoteEvents.Collect_Area
wait(0.3)
local hitbox = workspace.Collect_Coins_Area.HitBox_collect
local running = false
hitbox.Touched:Connect(function(hit)
	--on touch
	if not running then running = true
	local plr = game.Players.LocalPlayer.Name
	local sound = workspace.Collect_Coins_Area.sound
	local remote = game.ReplicatedStorage.RemoteEvents.Collect_Area
	local pi =  game.Players[plr]:FindFirstChild("leaderstats").Pieces
	if pi.Value >=0 then
		sound:Play()
	remote:FireServer()
	wait(5)
	running = false
end

6 comments

1

you're missing an "end"

1

"if not running then running = true end"

1

I think the problem is that you have to have an end after every if or for loop. Correct me if I'm wrong.

1

and at the last "end" you need to add ")" because that's a connection

1

you're missing 2 ends

0

Thank you all!

1 answer

try this:

wait(0.3)
local hitbox = workspace.Collect_Coins_Area.HitBox_collect
local running = false
local plr = game.Players.LocalPlayer
hitbox.Touched:Connect(function(hit)
	if not running then running = true end
	local sound = workspace.Collect_Coins_Area.sound
	local remote = game.ReplicatedStorage.RemoteEvents.Collect_Area
	local pi = plr.leaderstats.Pieces.Value
	if pi > 0 then
		sound:Play()
	end
	remote:FireServer()
	wait(5)
	running = false
end)

edit: i don't know exactly what i did because it's been over 26d since i posted this so i don't really know how to explain the answer

2 comments

0

stop spoonfeed. here, have my downvote.

0

Thank you for the answer but don't spoon feed.

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