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

Why won't this Voting Script work?

I have a Brick that, when you step on it, is supposed to change the votes displayed on it to what it was before +1

I have a NumValue named "Votes" that is default 0, and the TextLabel that goes on the brick that displays the votes is called "VotesDisplay" and it's default is 0 as well.

I'm not getting any errors when I run it. Nothing happens when I test the game, I step on the brick and the Vote Count stays the same.

VotingPads = game.Workspace.VotingPads.VoteMap1.Sign

timewait = 0

script.Parent.Touched:connect(function(hit)

VotingPads.Votes.Value = VotingPads.Votes.Value + 1
wait(0.1)
VotingPads.VotesDisplay.Text = VotingPads.Votes.Value

end)

4 comments

0

The note is meant to say to clarify what you want the script to do and what's going wrong. You're just telling us it's not working without explaining what it is doing.

0

It's simply not doing anything. I'm not getting any errors, and when I touch the brick nothing happens. The Vote Count just stays the same.

0

Wouldn't you use the "Changed" Event too?

0

I'm not sure ^ What is that used for?

1 answer

Try using this.

local votingPads = workspace.VotingPads.VoteMap1.Sign
local canVote = true --set a debounce so we can't vote more than once.

script.Parent.Touched:connect(function()
	if canVote then --if you can vote... do this
		local value = votingPads.Votes --sets a variable to the value
		local display = votingPads.VotesDisplay

		value.Value = value.Value + 1 --adds one to the value
		wait()
		display.Text = value.Value
		canVote = false --make it so you can't vote again.
	end
end)

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