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

Can someone please fix this GUI script?

Asked by
cboyce1 40
10 years ago

I'm trying to make a basic counting script. What is wrong with this?

function Touched(SoccerBall)
    Workspace.ScoreBoard.Score1.Frame.RedScore.Text = 1
    if Workspace.ScoreBoard.Score1.Frame.RedScore.Text == 1 then
        Workspace.ScoreBoard.Score1.Frame.RedScore.Text = 2
    end
end

script.Parent.Touched:connect(Touched)

1 answer

Log in to vote
0
Answered by
Marolex 45
10 years ago

Well first off, you dont actually have a counter, you're just changing the text to 2 each time after it gets past one.

goals = 0 --Starting number of goals
script.Parent.Touched:connect(function(SoccerBall)--firing the event
    goals = goals + 1
    Workspace.ScoreBoard.Score1.Frame.RedScore.Text = goals
end)
0
Yea I don't have a vast range of scripting knowledge so I just went to the basics. Thank you! cboyce1 40 — 10y
0
No problem, be sure to accept the answers so that people know it's completed. :) Marolex 45 — 10y
0
I recommend adding a line to see if it's name is Soccer ball. With this script, anybody could run into the goal and they'd get a point. Shawnyg 4330 — 10y
Ad

Answer this question