How to make this visible to people that join the server?

Hi. I have a scoreboard that I have made but it is on the client so while one persons screen shows 3-1 the others shows 0-0 because they have joined the server.

Here is the script:

local goal1 = workspace["Away Goal"].RedPart and workspace.goal2
local goal2 = workspace["Home Goal"].BluePart and workspace.goal1
local ball = workspace.TPS
local player = game.Players.LocalPlayer
local SB =  player.PlayerGui:WaitForChild("Start")
local ball = game.Workspace.TPS 
local team = game.Teams



ball.Touched:Connect(function(part)
	if part == goal1 then

		SB.Scoreboard.Score.LiverpoolScore.Text = SB.Scoreboard.Score.LiverpoolScore.Text +1
		game.ReplicatedStorage.LiverpoolParticles:Clone().Parent = workspace
		game.ReplicatedStorage.SparksTex:Clone().Parent = workspace

		wait (10)
		workspace.LiverpoolParticles:Destroy()
		workspace.SparksTex:Destroy()


	elseif part == goal2 then
		SB.Scoreboard.Score.ParisScore.Text = SB.Scoreboard.Score.ParisScore.Text +1
		game.ReplicatedStorage.ParisParticles:Clone().Parent = workspace
		game.ReplicatedStorage.SparksTexPSG:Clone().Parent = workspace

		wait (10)
		workspace.ParisParticles:Destroy()
		workspace.SparksTexPSG:Destroy()


	end
end)

Just do the same thing with serverside script and create values anywhere, because if its client sided script it will stay like this and be unfixable. If you will find a way to transfer data from client to client then exploiters will be able to abuse it anyways.

Snipping this post, not relevant.

--SERVER SCRIPT--
local goal1 = workspace["Away Goal"].RedPart and workspace.goal2
local goal2 = workspace["Home Goal"].BluePart and workspace.goal1
local storage = game:GetService("ReplicatedStorage")
local ball = workspace:WaiForChild("TPS")
local team = game:GetService("Teams")
local liverpoolScore = storage:WaitForChild("LiverpoolScore")
local parisScore = storage:WaitForChild("ParisScore")

ball.Touched:Connect(function(part)
	if part == goal1 then
		liverpoolScore.Value += 1
		storage.LiverpoolParticles:Clone().Parent = workspace
		storage.SparksTex:Clone().Parent = workspace
		task.wait(10)
		workspace.LiverpoolParticles:Destroy()
		workspace.SparksTex:Destroy()
	elseif part == goal2 then
		parisScore.Value += 1
		storage.ParisParticles:Clone().Parent = workspace
		storage.SparksTexPSG:Clone().Parent = workspace
		task.wait(10)
		workspace.ParisParticles:Destroy()
		workspace.SparksTexPSG:Destroy()
	end
end)
--LOCAL SCRIPT--
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local storage = game:GetService("ReplicatedStorage")
local liverpoolScore = storage:WaitForChild("LiverpoolScore")
local parisScore = storage:WaitForChild("ParisScore")

players.PlayerAdded:Connect(function(player)
	local playerGui = player:WaitForChild("PlayerGui")
	local screenGui = playerGui:WaitForChild("ScreenGui")
	local label = screenGui:WaitForChild("TextLabel")
	label.Text = liverpoolScore.Value.." : "..parisScore.Value
end)

function updateGui()
	local playerGui = player:WaitForChild("PlayerGui")
	local screenGui = playerGui:WaitForChild("ScreenGui")
	local label = screenGui:WaitForChild("TextLabel")
	label.Text = liverpoolScore.Value.." : "..parisScore.Value
end

liverpoolScore.Changed:Connect(updateGui)
parisScore.Changed:Connect(updateGui)

I’ve made the scoring script a server script (that way the score replicates across the server to every client), each team has an IntValue instance which represents their score (which is placed inside ReplicatedStorage), when a new player joins his/her Gui is updated to show this new score, and whenever the score changes the Gui is updated too, you might need to change some of the references slightly (to match how the instances are organised in your game) but this will work.

your scripts give a bunch of infinite yeild possibilties, the only things i like to use waitforchild for is player gui

It isn’t meant to be copied & pasted, in the above block of text I stated that you’ll need to change the references to some instances to fit how your game is currently organised.

local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local storage = game:GetService("ReplicatedStorage")
local liverpoolScore = storage:WaitForChild("LiverpoolScore")
local parisScore = storage:WaitForChild("ParisScore")
local playerGui = player:WaitForChild("PlayerGui")
local scoreBoard = playerGui:WaitForChild("Start")
local score = scoreBoard:WaitForChild("Score")
local liverpoolUIScore = score:WaitForChild("LiverpoolScore")
local parisUIScore = score:WaitForChild("ParisScore")

players.PlayerAdded:Connect(function(player)
	liverpoolUIScore.Text = liverpoolScore.Value
	parisUIScore.Text = parisScore.Value
end)

function updateGui()
	liverpoolUIScore.Text = liverpoolScore.Value
	parisUIScore.Text = parisScore.Value
end

liverpoolScore.Changed:Connect(updateGui)
parisScore.Changed:Connect(updateGui)

Here, I’ve made it fit your game (I think it matches) make 2 IntValue instances named “LiverpoolScore” & “ParisScore” and place them inside the ReplicatedStorage folder. The server script from earlier doesn’t need changing.

2 Likes

here is where i have my scoreboard stored.
UFF Match Pitch - Roblox Studio (gyazo.com)

You store the scores in StringValue instance? And what spelling mistakes?

is this meant to work? or did i put it in a wrong script