My Roblox Score UI won't update

I’m trying to make a scoring system for my soccer like game and the Score UI won’t update. I’ve tried using RemoteEvent and several other ways but non of it worked. Can anyone please help me?

ServerScriptService Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sphere = workspace.Sphere
local BlueScore = ReplicatedStorage.BlueScore
local RedScore = ReplicatedStorage.RedScore

Sphere.Touched:Connect(function(Touched)
	if Touched.Name == "BlueGoal" then
		RedScore.Value = RedScore.Value + 1
		Sphere.Position = Vector3.new(0,10,0)
	end
	if Touched.Name == "RedGoal" then
		BlueScore.Value = BlueScore.Value + 1
		Sphere.Position = Vector3.new(0,10,0)
	end
end)

Local Script that I put in the GUI:

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

local ScoreGUI = Players.LocalPlayer:WaitForChild("PlayerGUI"):WaitForChild("ScoreGUI")
local RedScore = ReplicatedStorage.RedScore
local BlueScore = ReplicatedStorage.BlueScore

RedScore.Changed:Connect(function()
	print("CHANGED")
	ScoreGUI.Red.Text = RedScore
end)

BlueScore.Changed:Connect(function()
	print("CHANGED")
	ScoreGUI.Blue.Text = BlueScore
end)

I believe RedScore (and BlueScore) are Int / Number Values,
You’re trying to set your text to an instance, try to set the text to the value of that score.

ScoreGUI.Red.Text = RedScore.Value
ScoreGUI.Blue.Text = BlueScore.Value

This is only from a first glance, I’ll now take another glance to see more.

1 Like

This is correct, additionally the ‘Changed’ signal of ValueObjects (IntValues, NumberValues etc.) pass their new values to any callback functions connected to them.

local Workspace = workspace
local Value = Workspace.Value --NumberValue in 'Workspace'.

local function OnValueChanged(NewValue)
	print(NewValue) --Prints the value of the 'math.pi' constant.
end

Value.Changed:Connect(OnValueChanged)
Value.Value = math.pi
2 Likes