Ui Text not updating

Hello! I am creating a four corners game, and the game itself works, but I have a text, and I want when the corner that is going to die is chosen, to say in that text, which one it was, for some reason the text is changed ( since I put a
print(text.Text)
But the UI doesn’t change, what can I do?
(does not show any error in the output)
the error line:

text.Text = selectedCorner.Name.." Died!"

The complete script:

local rs = game:GetService("ReplicatedStorage")
local walls = rs:WaitForChild("Walls")
local killWalls = rs:WaitForChild("Killwalls")
local folder = rs:WaitForChild("Corners")
local cornerFolder = workspace:WaitForChild("Corners"):GetChildren()
local glass = workspace.Glass
local ts = game:GetService("TweenService")
local gui = game.StarterGui.GameUI
local text = gui.TimeText
cornerFolder.Parent = workspace

local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local goal = {Size = Vector3.new(0, 0, 0)}

local function round()
local selectedCorner = cornerFolder[math.random(1, #cornerFolder)]
local ogSize = selectedCorner.Size
local tween = ts:Create(selectedCorner, info, goal)
print(selectedCorner)
tween:Play()
walls.Parent = workspace
killWalls.Parent = workspace
glass.Parent = rs
text.Text = selectedCorner.Name.." Died!"
text.TextColor = selectedCorner.BrickColor
print(text.Text)
print(text.TextColor)
wait(1)
selectedCorner.Parent = folder
wait(5)
selectedCorner.Parent = workspace
walls.Parent = rs
killWalls.Parent = rs
glass.Parent = workspace
selectedCorner.Size = ogSize
end
wait(3)
while true do
wait(10)
round()
end

Thanks!

1 Like

Where are you running this, client or server

2 Likes

damn, you are right, is server-sided, but how to make it run in a client sided? Becouse the entire script is in serverscriptservice

1 Like

A couple of things you could do:

  1. The easy way - Paste the entire thing into a LocalScript, place it in anywhere a LocalScript will work (except from ReplicatedFirst), and change this line

to local gui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")

  1. The slightly more annoying and time-consuming way (only slightly) - Paste the whole thing into a LocalScript and parent the new script to the Gui in StarterGui. Then, change the line:

to local gui = script.Parent

The problem was that you were editing the label in StarterGui, not the player’s PlayerGui. You could do this server-side, but it’s better to let the client handle their own GUI.

Note: Just to let you know, parenting stuff to the Workspace through a LocalScript doesn’t work - you should do that server-side

2 Likes

[quote=“12345koip, post:4, topic:2846474, username:12345koip”]
Note: Just to let you know, assigning parent items to Workspace via a LocalScript does not work; you must do it on the server side.
[/appointment]

Thanks, but can I make the parent of something the workspace? (even if what I’m raising is not originally in the workspace) also, what do you recommend for creating a parent variable in the workspace? (explaining further, you said I can’t parent things to the workspace via local script and I need to do it server-sided, how can I do it?) Sorry, I’m a kinda new to scripting.
Thank you!

You could use a RemoteEvent to tell the server to parent something to the Workspace. Just don’t pass that thing along the event, pass something it can be identified by, like a name.

A RemoteEvent in ReplicatedStorage called ParentAPart

--client
game:GetService("ReplicatedStorage"):WaitForChild("ParentAPart"):FireServer("Part1")
--server
game:GetService("ReplicatedStorage").ParentAPart.OnServerEvent:Connect(function(player, part)
    if areaYourPartIsParentedTo:FindFirstChild(part) then
        areaYourPartIsParentedTo[part].Parent = workspace
    end
end)

This code is quite unoptimised/inefficient, but I hope it helps.

Dosen’t work:
Server Script (in serverscriptservice)

game.Players.PlayerAdded:Connect(function(plr)
	local rs = game:GetService("ReplicatedStorage")
	local event = game:GetService("ReplicatedStorage"):WaitForChild("ParentWorkspace")
	local parts = {rs:WaitForChild("Killwalls"),
		rs:WaitForChild("Walls"),
	}	
	event.OnServerEvent:Connect(function(plr, parts)
		if rs:FindFirstChild("Killwalls") and rs:FindFirstChild("Walls") then
			rs[parts].Parent = workspace
		end
	end)
end)

Added line to the local script (in starterplayerscripts)

parentEvent:FireServer("parts")
1 Like

Maybe a syntax error. There is an unneccessary comma at the end.
Should be:

local parts = {
    rs:WaitForChild("Killwalls"),
    rs:WaitForChild("Walls")
}

Let me know if there’s any errors/warnings in the output.
I hope this helps.

You’re changing it for starterGui and NOT players, hence is way they can’t see any edits.