Changing text via intvalue not working

Hi!

I have a scoreboard script which is meant to add 1 every time the team scores. I am using intvalues for this, and it doesn’t change the text at all.

Here is the script:

local player = game.Players.LocalPlayer

local gui = player.PlayerGui:WaitForChild("Start", math.huge)

local val = Instance.new("IntValue")

val.Parent = game.ReplicatedStorage

val.Name = "ajax"

local val1 = Instance.new("IntValue")

val.Parent = game.ReplicatedStorage

val.Name = "inter"

local Away = workspace.AwayPart:GetChildren()

local Home = workspace.HomePart:GetChildren()

local HomeGK = workspace.HomeGKPart:GetChildren()

local AwayGK = workspace.AwayGKPart:GetChildren()

local Ref = workspace.RefPart:GetChildren()

local playersService = game:GetService("Players")

local scoreBoardGui = workspace.Score.ScoreboardGui

local elfScore = scoreBoardGui.Score.ParisScore

local gnomeScore = scoreBoardGui.Score.LiverpoolScore

local status = scoreBoardGui.Status

local timer = scoreBoardGui.Timer

local team = game.Teams

local goal1 = workspace["Away Goal"].WhitePart and workspace.goal2

local goal2 = workspace["Home Goal"].RedPart and workspace.goal1

local ball = workspace.TPS

local originalPosition = ball.Position

ball.Touched:Connect(function(part)

if part == goal2 then

val.Value = val.Value +1

gui.Scoreboard.AjaxScore.Text= tostring(val)

elseif part == goal1 then

val1.Value = val.Value +1

gui.Scoreboard.InterScore.Text = tostring(val)

end

end)

Any help would be appreciated! Thanks.

The problem is you’re converting a string into a string. Try changing all tostrings() to just gui.Scorebard.Blahblahblah.Text = val

1 Like

i tried that already, and yeah it doesnt work

I totally forgot about tonumber(), try that.

1 Like

i have never seen this before

can you explain what is math.huge for there

and if you have any errors tell us

it just throws this error at me:

its to stop the “infinite yield” error (the string timeout)

maybe its because val and val1 are instaces not values try val.value

That’s if you’re trying to change it to val’s name:

tostring(val.Name)

or if you’re trying to change it to val’s value:

tostring(val.Value)
1 Like

You have made typos between val and val1. I think this is the working version of your script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

local player = Players.LocalPlayer
local gui = player:WaitForChild("PlayerGui"):WaitForChild("Start", math.huge)

local val = Instance.new("IntValue", ReplicatedStorage)
val.Name = "ajax"

local val1 = Instance.new("IntValue", ReplicatedStorage)
val.Name = "inter"

local Away = workspace.AwayPart:GetChildren()
local Home = workspace.HomePart:GetChildren()
local HomeGK = workspace.HomeGKPart:GetChildren()
local AwayGK = workspace.AwayGKPart:GetChildren()
local Ref = workspace.RefPart:GetChildren()

local scoreBoardGui = workspace.Score.ScoreboardGui
local elfScore = scoreBoardGui.Score.ParisScore
local gnomeScore = scoreBoardGui.Score.LiverpoolScore
local status = scoreBoardGui.Status
local timer = scoreBoardGui.Timer

local goal1 = workspace["Away Goal"].WhitePart and workspace.goal2
local goal2 = workspace["Home Goal"].RedPart and workspace.goal1

local ball = workspace.TPS
local originalPosition = ball.Position

ball.Touched:Connect(function(part)
	if part == goal2 then
		val.Value += 1
		gui.Scoreboard.AjaxScore.Text = val.Value 
	elseif part == goal1 then
		val1.Value += 1
		gui.Scoreboard.InterScore.Text = val1.Value 
	end
end)
1 Like

it doesn’t work, and this doesn’t work either

local player = game.Players.LocalPlayer

local gui = player.PlayerGui:WaitForChild("Start")
local val = game.ReplicatedStorage:WaitForChild("Ajax")
local val1 = game.ReplicatedStorage:WaitForChild("Inter")


local goal1 = workspace["Away Goal"].WhitePart and workspace.goal2
local goal2 = workspace["Home Goal"].RedPart and workspace.goal1
local ball = workspace.TPS

ball.Touched:Connect(function(part)
	if part == goal2 then
		val.Value = val.Value +1
		gui.Scoreboard.AjaxScore.Text= val



	elseif part == goal1 then
		val1.Value = val.Value +1
		gui.Scoreboard.InterScore.Text = val1
		




	end


end)

Did you try using my script, without modifications? If so what error did you got?

1 Like

try printing val and val1 and gui.Scoreboard.Ajaxscore.text

1 Like

yes i have, and it throws this error

Use the updated version of my code, you have to instead use val1.Value and val.Value.

it works, but it puts a 1 over the text

image

Is that 2 different TextLabels or “0-10”?

1 Like

nevermind, i found an overlapping text label. thanks for your help!

1 Like

wait one more thing, how would i make it so if the value hits 7 the values and the text reset to 0?

if part == goal2 then
	val.Value += 1
	if val.Value > 7 then 
		val.Value = 0
	end
	gui.Scoreboard.AjaxScore.Text = val.Value 
elseif part == goal1 then
	val1.Value += 1
	if val1.Value > 7 then 
		val1.Value = 0
	end
	gui.Scoreboard.InterScore.Text = val1.Value 
end