Hello, recently I’ve been trying to make a simple GUI that either closes if you click the ‘play’ button and kicks you if you click ‘don’t play’.
local gui = game.StarterGui.welcome
gui.Button.MouseButton1Click:Connect(function()
gui.Frame.Visible = false
end)
gui.lolButton.MouseButton1Click:Connect(function(plr)
plr:Kick("You aren't banned, you just didn't want to play lol")
end)
Isn’t a text button supposed to have the MouseButton1Click function? I have checked that each item is parented correctly so the ‘valid member’ error doesn’t pop up.
Edit: I noticed I wrote MouseButton1Click incorrect and have fixed it, but it did not fix the script
Aside from the fact that you should be editing the object located inside of PlayerGui rather than StaterGui in this situation, you typed “MouseButtonClick1” rather than MouseButton1Click.
For future reference, you can click on the “View” tab in studio and then select the “Object Browser.” It has a list of objects with their properties & functions.
Surely the PlayerGui doesn’t take any longer than 5 seconds to lead into the client? Even if it does takes longer, just change :WaitForChild(“PlayerGui”) to :WaitForChild(“PlayerGui”, (time to wait))
This works, just put a RemoteEvent in replicated storage.
Local script inside of a ScreenGui:
local PlayButton = script.Parent.PlayButotn
local DontPlayButton = script.Parent.DontPlayButton
local Player = game.Players.LocalPlayer
PlayButton.MouseButton1Click:Connect(function()
--make the frame invisible
end)
DontPlayButton.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer(Player)
end)
ServerScript:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
player:Kick("You didnt wanted to play")
end)
Edit: I didn’t realize you could do it from the client.
Seems like all he wants to do is kick the local player if they decide to click the “don’t play” button, which means that there’s no need for separating it between the server and client with a remote event. He can simply just kick the local player.
There’s also no need to pass “Player” as an argument - the player that fires a remote is automatically sent.
You don’t use StarterGui to change a players ui. You have to use PlayerGui. The StarterGui just clones the children into PlayerGui when entering a game