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

Why won't this Voting Script work?

Asked by
Agios 10
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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)
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. FearMeIAmLag 1161 — 9y
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. Agios 10 — 9y
0
Wouldn't you use the "Changed" Event too? woodengop 1134 — 9y
0
I'm not sure ^ What is that used for? Agios 10 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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)
Ad

Answer this question