Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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.

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 sodaghost1 34 — 6y
0
The script works in test mode, however, it does not work when ingame. AntonioVillavicencio 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

0
If this was to be put in a group game, does CreatorID still work with the owner / creator of the place? AntonioVillavicencio 0 — 6y
0
Also, can you put a specific ID in place of CreatorID? AntonioVillavicencio 0 — 6y
0
Oh, it's a group game? Just replace local User = game.CreatorId with local User = 99964993 That's your Id btw lel sodaghost1 34 — 6y
0
Tried it. "launch" is not a valid member of SURFACEGUI. Confused AntonioVillavicencio 0 — 6y
Ad

Answer this question