Here is the LocalScript located inside of a button
script.Parent.MouseButton1Click:Connect(function() local owner = "Player" player = game.Players.LocalPlayer.Name game.ReplicatedStorage.RemoteEvent:FireServer() print("remote fired!") print(player) end)
The script triggers a RemoteEvent which connects to a script in ServerScriptService, telling the Tutorial GUI to close.
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() print("Close button loaded") button = game.Players.player.PlayerGui.Tutorial.Intro.No window = game.Players.player.PlayerGui.Tutorial function onClicked(GUI) window:remove() end game.Players.player.PlayerGui.Tutorial.Intro.No.MouseButton1Click:connect(onClicked) end)
However I get this error when I press the button:
player is not a valid member of Players
Here is where the error is located:
button = game.Players.player.PlayerGui.Tutorial.Intro.No
So I guess the variable can't be placed in a script that way? When I tried replacing "player" with my own username it worked. There's something wrong I did with the variables.
-- Under button, LocalScript local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() player.PlayerGui.Tutorial:Destroy() -- remove is deprecated, use Destroy end)
Ok so there are a few problems I see but I will address two. Number one: Closing a tutorial can be handled on the client. As long as it does not affect the player's standing in the game or money or whatever, the client can handle it. If I were a hacker, would I be saying: "yay I can open and close this tutorial whenever I want!"? I don't think so. If it is safe for the client to do it, let the client do it. Second problem: even if the player variable was able to be accessed by the ServerScript(which it is not) your code would not work. The reason is that you have set player
to equal a string, which is the player's Name. You cannot do: game.Players."playerName". One thing you could do is use :FindFirstChild(player). I hope this helps and have a great day scripting!