How do I make the person click a brick and then they get kicked

script.Parent.ClickDetector.MouseClick:Connect(function()
	game.StarterGui.BlackScreen.Enabled = true
	LocalPlayer:Kick()
end)

2 things:

  1. The BlackScreen gui doesn’t even come up at all
  2. The Player doesnt get kicked.

error:

image

3 Likes

I’m pretty sure LocalPlayer is a property of Players. Edit: I’m also sure that you’d have to enable it from the player’s PlayerGui instead of StarterGui.

local players = game:GetService("Players")

local localPlayer = players.LocalPlayer

script.Parent.ClickDetector.MouseClick:Connect(function()
    localPlayer.PlayerGui.BlackScreen.Enabled = true
    localPlayer:Kick()
end)
5 Likes

StarterGui is not what the player sees.

script.Parent.ClickDetector.MouseClick:Connect(function(player)
player.PlayerGui.BlackScreen.Enabled = true
player:Kick()
end)
1 Like

you have to use the mouse(local script):

local Mouse = game.Players.LocalPlayer:GetMouse()

Mouse.Button1Down:Connect(function()
    if Mouse.Target = workspace.thePartThatKicks then
        player:Kick()
    end
end

You realise that I have a clickdetector right…?

3 Likes

game.Players.LocalPlayer only returns the player if it is written in a LocalScript, and im pretty sure the player can only be kicked from the server (not sure about that though). If so, you are going to want a remoteEvent sending a message to a serverScript telling it to kick the player. Although, if you are using a clickDetector, im pretty sure that that can pass input to a serverScript (in that case, have the serverScript detect the player’s input and then kick the player)

MouseClick ( Instance playerWhoClicked )

Your using a clickdetector, correct?
ClickDectector.MouseClick gives you the player who clicked it, so you could do this:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	game.StarterGui.BlackScreen.Enabled = true
	player:Kick()
end)

LocalPlayer is only accessible in a LocalScript, and its a property of the Players Service.

@Dudeguy90539 You can actually kick players on the client, but it doesn’t work if you try to kick a player other than yourself. Because the disconnection is being handled on the clients, I’m pretty sure it can be bypassed.

1 Like

script.Parent.ClickDetector.MouseClick:connect(function()
game.Players.LocalPlayer.PlayerGui.BlackScreen.Frame.Visible = true
game.Players.LocalPlayer:Kick()
end)

Try enabling the GUI and keeping the frame.visible false and try the script I put above.

Hope it helps.

There’s no more errors but it still doesn’t work

Don’t use Enabled, make the screen UI not visible at start and replace Enabled with visible.

I already did do that but it doesn’t work

GUIs use the Enabled Property whereas Frame uses Visible

And @Yaahz have you tried a script that’s filtering enabled compatible?

May I see? It should be working in that case.

script.Parent.ClickDetector.MouseClick:Connect(function(player)
player.PlayerGui.BlackScreen.Frame.Visible = true
player:Kick()
end)

Filtering enabled is how Roblox makes sure the client and server are connected without hackers interrupting other clients. (In other words if a hacker tries to delete the map, it only happens in his client / game and doesnt affect anyone else.)

It uses remote events. I’ll write a script in a bit.

@AndrewsDeving101 how do you write scripts in the reply section?

That didn’t work either and no error

Yes. For you to kick someone, you might need to use remote events as ROBLOX servers may see it as a hacker trying to kick someone out.

We can try a filtering enabled script. 1 min

I have no idea how to do that (30characterslimitisweird)

Can you show me the entire script and the explorer so that it can be more easier to find out the solution, also I think @AndrewsDeving101 might be right because your using the StarterGui instead of the PlayerGui. If the black screen is not enabled then you need to call the BlackScreen through the PlayerGui

I just give up its impossible to do