Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

The GUI button does not appear for a specific player, outdated method?

countdown = 11

username = "AntonioVillavicencio"
if game.Players.LocalPlayer.Name == username then
	script.Parent.launch.Visible = true
end

script.Parent.launch.MouseButton1Click:connect(function()
	
	while countdown > 0 do
		countdown = countdown - 1
		script.Parent.COUNT.Text = countdown
		wait(1)
	end
	
	script.Parent.COUNT.Text = "WE HAVE LIFT-OFF"
	
	game.ReplicatedStorage:WaitForChild("workspaceEvents").rockets.launch:FireServer()
end)

why does the following segment not work :

username = "AntonioVillavicencio"
if game.Players.LocalPlayer.Name == username then
	script.Parent.launch.Visible = true
end

Ingame, the button does not appear. The rest of the script works smoothly.

2 comments

0

Have you checked on the in-game developer console? Hit 'F9' or chat '/Console' to open it up. Click on 'Server Log' or 'Client Log' and see what it says there. Also, I suggest using UserId instead of name because if you ever change your username on ROBLOX, you don't need to update the script because NOBODY can change their UserId. If it's your account, (Owner of the game) just use, game.CreatorId

0

The script works in test mode, however, it does not work when ingame.

1 answer

Here, try this instead. I recommend you put this in a LocalScript because a Server Script cannot read "LocalPlayer".

That could have been your problem if you're using a normal Script. USE LocalScript on Client Side if you're going to refer to it as the Local Player.

-- AntonioVillavicencio

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Player = game.Players.LocalPlayer

local CountDown = 11
local User = game.CreatorId

if Player.UserId == User then
	script.Parent.launch.Visible = true
end

script.Parent.launch.MouseButton1Down:Connect(function()
	while wait(1) and CountDown > 0 do
		CountDown = CountDown - 1
		script.Parent.COUNT.Text = CountDown
	end
	script.Parent.COUNT.Text = 'WE HAVE LIFT-OFF'
	ReplicatedStorage:WaitForChild("workspaceEvents").rockets.launch:FireServer()
end)

If you wanna add in extra info, replace all of line 16 with the following code;

if script.Parent.COUNT.Text > 1 then
	script.Parent.COUNT.Text = CountDown .. ' seconds until lift-off.'
elseif script.Parent.Count.Text == 1 then
	script.Parent.COUNT.Text = CountDown .. 'second until lift-off.'
end

Lolll

4 comments

0

If this was to be put in a group game, does CreatorID still work with the owner / creator of the place?

0

Also, can you put a specific ID in place of CreatorID?

0

Oh, it's a group game? Just replace local User = game.CreatorId with local User = 99964993 That's your Id btw lel

0

Tried it. "launch" is not a valid member of SURFACEGUI. Confused

This discussion is preserved as it was. New answers, comments, and votes are closed.