My script:
script.Parent.MouseButton1Click:Connect(function(plr)
plr:Kick()
end)
Why this dont work?
My script:
script.Parent.MouseButton1Click:Connect(function(plr)
plr:Kick()
end)
Why this dont work?
The event doesn’t have a player argument.
Im new on forum i dont know what type is it
Use the LocalPlayer property of the Players service to kick the player.
https://create.roblox.com/docs/reference/engine/classes/Players
client sided can be bypassed by exploiters in game.StarterGui…
I would do:
Even though you should try do more with the
code because of security in my opinion…
Local Script (Inside of a Button…)
local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local player = players.LocalPlayer
local event = replicatedStorage.RemoteEvent
local button = script.Parent
button.MouseButton1Click:Connect(function()
local table = {
Action = "KickSelf",
Message = "You kicked yourself using a remote event!",
}
event:FireServer(table)
end)
Server Script (Inside of ServerScriptService)
local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage.RemoteEvent
event.OnServerEvent:Connect(function(player, table)
if table.Action == "KickSelf" then
player:Kick(table.Message)
end
end)
Its because you are running it inside a local script
Thats not necessary. You don’t need an argument in :Kick()
It is optional, but displays a message to the player being kicked.
Yes, its optional but won’t affect whether or not the function works
I said: the mousebutton1click event does NOT have a player argument.
It does have a player argument? Its defined as “plr”.
It does not,
If I am not mistaken, that is not called a player argument. Thats a regular argument
and also
script.Parent.MouseButton1Click:Connect(function()
print("test")
end)
works
i don’t know what is a regular argument.
Parameters are typed inside the () that comes after a function’s name.
They look like this:
local function FunctionName(parameterName)
parameterName += 20 -- adding 20 onto the number..
end)
local number = 5
FunctionName(number)
The actual information that gets passed through the parameter is called an argument.
It didn’t work because there is no player
This is the script with player (local script)
script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer:Kick("You decided to leave the game.")
end)
Thank you so much!!! Now it work!