Script won't change GUI Button Text

Hello! So I recently made a game I’m working on multiplayer, and I wanted to make it so only one person can claim a character, so I tried creating a script to do that, basically, if a Intvalue in Workspace has a value of 0, then whenever someone clicks a button, it enables the script and changes the Intvalue to 1. However, the script does work, but it doesn’t change the text of the button. I am unable to get it to work, so I came here for help!

Script:

local RemoteEvent = game:GetService("ReplicatedStorage").FireChar
local HumanoidDescription = workspace.Morph["Morph Script"].Settings:FindFirstChildOfClass("HumanoidDescription")

RemoteEvent.OnServerEvent:Connect(function(Player)
	if game.Workspace.Value1.Value == 1 then
		game.StarterGui.LoadingScreen.Frame2.Bob.Text = "Taken"
		wait(4)
		game.StarterGui.LoadingScreen.Frame2.Bob.Text = "Bob"
	else
		game.StarterGui.LoadingScreen.Frame2.Bob.LocalScript.Disabled = false
		Player.Character.Humanoid:ApplyDescription(HumanoidDescription)
		game.Workspace.Value1.Value = 1
	end	
end)

Location:
image

GUI Location:

1 Like

You’re trying to change the text on the StarterGui version. In an active server, the LoadingScreen is in the PlayerGui inside the Player

2 Likes

You are using the StarterGui which would only change the gui at the start, would have to use a LocalScript to access the PlayerGui and do something like this:

local RemoteEvent = game:GetService("ReplicatedStorage").FireChar
local HumanoidDescription = workspace.Morph["Morph Script"].Settings:FindFirstChildOfClass("HumanoidDescription")

RemoteEvent.OnServerEvent:Connect(function(Player)
	for i,v in pairs(game:GetService("Players").GetPlayers()) do
		if game.Workspace.Value1.Value == 1 then
			v.PlayerGui.LoadingScreen.Frame2.Bob.Text = "Taken"
			wait(4)
			v.PlayerGui.LoadingScreen.Frame2.Bob.Text = "Bob"
		else
			v.PlayerGui.LoadingScreen.Frame2.Bob.LocalScript.Disabled = false
			Player.Character.Humanoid:ApplyDescription(HumanoidDescription)
			game.Workspace.Value1.Value = 1
		end	
	end
end)
3 Likes

so, unless its a local script
if you do it on a server script, it wouldnt work unless the gui is restarted again

You assigned the parameters wrong, here is how it should be done.

Player.PlayerGui.LoadingScreen.Frame2.Bob.Text = "Taken"
wait(4)
Player.PlayerGui.LoadingScreen.Frame2.Bob.Text = "Bob"

StarterGui is used as a template for the UI the player sees. If you change something in StarterGui, the player would need to rejoin to actually see the change. The UI the player can actually see is located in Player.PlayerGui.

Like everyone said, you’re changing the StarterGUI’s text. You’ll need to use a LocalScript to fix this problem.

This method doesn’t work, so use RemoteEvent:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
-- Now the script for LocalScript
RemoteEvent.OnClientEvent:Connect(function (Text)
  TextLabel.Text = Text
end)
-- Now script for ServerScript
RemoteEvent:FireClient("Taken")
wait(4)
RemoteEvent:FireClient("Bob")
-- Or
-- Now the script for LocalScript
RemoteEvent.OnClientEvent:Connect(function (Number)
  if Number == 1 then
    TextLabel.Text = "Taken"
    wait(4)
    TextLabel.Text = "Bob"
  end
end)
-- Now script for ServerScript
RemoteEvent:FireClient(1)

Here’s how to use RemoteEvent: Bindable Events and Functions | Roblox Creator Documentation
And how to use BindableEvent: BindableEvent | Roblox Creator Documentation