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.
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