-
What do you want to achieve?
I am trying to update a screengui on the client side. The screengui shows the player name and their points in respective text labels. The name is updated when the player touches a part in game and the points are manually given each time I press a button in game. -
What is the issue?
The issue is that the screengui will only update on the server but not on the client UNLESS the player respawns. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
The only “solution” or update to my problem was that I swapped the screengui with a surface gui and it appears to work on there on the client side but when I use the screengui i have to respawn to see it update.
This is my touch part scripts to get the player name in a text label in the screengui. The local script is in the StarterGui and the server script is in the ServerScriptService.
-- Local script
local TouchPart= game.Workspace.Scale.RightScale.TouchPart
TouchPart.Touched:Connect(function()
game.ReplicatedStorage.RightNameFunction:InvokeServer(TouchPart)
end)
-- Local script
local R1= game.Workspace.Scale.R1
R1.ClickDetector.MouseClick:Connect(function()
game.ReplicatedStorage.RightScoreFunction:InvokeServer(R1)
end)
This is my button scripts to update the player points in the a label in the screengui. The local script is in the StarterGui and the server script is in the ServerScriptService.
-- Local script
local TouchPart= game.Workspace.Scale.RightScale.TouchPart
TouchPart.Touched:Connect(function()
game.ReplicatedStorage.RightNameFunction:InvokeServer(TouchPart)
end)
-- Server script
game.ReplicatedStorage.RightScoreFunction.OnServerInvoke = function(player,code)
local Score = game.StarterGui.RightPlayer.Frame.ScoreTextLabel
Score.Text = Score.Text + '1'
end