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

In StarterGui there should be a screengui named BlackScreen (Enabled) with a frame named Frame. Then paste this in a script in a part with a click detector inside:

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

Don’t give up come on, lets do this together. Just send me the script and I’ll fix it.

It’s destroyed I’ve already broken it too much

It’s fine if you can send the script over we can give it a shot and fix it up. Is it just the gui and kick in the script or is there another function in it?

From what I’m guessing its,

Brick > Click Detector > Script
and
StarterGui > BlackScreen > Frame

Correct?

i removed the other parts but it doesnt work if its in a localscript but then it doesnt work if its all in a script

It shoudltn be a local script. It has to be a script.

Wait, I’ll send you what it should be sent.

local player = game.Players.LocalPlayer
local BlackScreen = game.Players.PlayerGui.BlackScreen

script.Parent.ClickDetector.MouseClick:Connect(function()
BlackScreen.Enabled = true
player:Kick(“You have been kicked”)

local players = game:GetService(“Players”)

local LocalPlayer = players.LocalPlayer

script.Parent.ClickDetector.MouseHoverEnter:Connect(function()
script.Parent.Material = “Neon”
end)

script.Parent.ClickDetector.MouseHoverLeave:Connect(function()
script.Parent.Material = “Metal”
end)

script.Parent.ClickDetector.MouseClick:Connect(function()
workspace.Music.helloworld:Stop()
game.StarterGui.BlackScreen.Enabled = true
script.Parent.Shutdown:Play()
LocalPlayer:Kick(“Computer Shutdown…”)
end)

2 Likes

Actually, it should be a LocalScript since its interacting with the GUI.

But a local script cannot kick a player, only a script can.

1 Like

Is Players a service? Hmm, I’ve never heard of that before.

1 Like

I am on mobile and won’t be on the computer to write the script for the rest of the day. I can’t type it right now.

The localscript doesn’t actually stop or play the song so it’s just going to have to completely be removed there’s no point

Yes it is, it’s commonly used to find local player as of my experience.

1 Like

Why won’t you try doing when a player touches a brick?

Because it’s a game where your camera is in a locked place and you aren’t anywhere near it

1 Like

The reason why LocalPlayer is a nil value is because you didn’t call it earlier.

For the record yes a local script can kick a player. See Player | Documentation - Roblox Creator Hub

3 Likes

Good golly what is happening in this thread? Let’s start this again. OK so you want to make a black frame appear in the players gui and the player disconnect on clicking a brick. Changes to ui should be done locally, and contrary to what some replies state, you can safely kick a client locally, but this may not be 100% secure against exploiters if that’s a concern. As this uses a gui, it’s probably best to use a local script placed inside the frame you want to make appear. Set up the frame plus localscript inside a ScreenGui inside StarterGui and then turn ‘visible’ for the frame off. Then add this code:

local ClickDetector = game.Workspace.... 
local Frame = script.Parent
local Player = game.Players.LocalPlayer
ClickDetector.MouseClick:Connect(function()
   Frame.Visible = true
   Player:Kick() 
end) 

And just make sure to point the click detector and frame variables to the right places. Apologies for any typing errors, I’m sending this from my phone.

With regards to using game:GetService() for players and workspace, yes, this is technically the ‘right’ way to do it, but please don’t needlessly clog up help threads pointing this out and debating about it, as it just confuses the topic and detracts from actually solving the problem.

10 Likes

Don’t bother, thank’s anyway I’ll just remove the feature smh