Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Anyone know how to make a block that kicks you out of the game in a amount of time?

Asked by 3 years ago

So I'm making a game like get a snack at 4am and i need a brick that kicks you out of the game in a certain amount of time. I dont have any code for this but anyway thanks!

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

if you want it to kick in an amount of time:

local certainAmount = 5 -- your custom amount here
local Player = <PLAYER HERE> -- the player to kick
local Reason = "i love waffles" -- the reason
wait(certainAmount) -- waiting a certain amount
Player:Kick(Reason) -- kicking the player

or it can kick in an amount of time when touched:

local certainAmount = 5 -- your custom amount here
local Reason = "i love waffles" -- the reason to kick
local Players = game:GetService("Players) -- getting the players server
script.Parent.Touched:Connect(function(hit) -- when the part is touched
    if hit.Parent:FindFirstChildWhichIsA("Humanoid") then -- checking if the "hit" has a humanoid
if Players:FindPlayerFromCharacter(hit.Parent) then -- making sure the hit is a player
local Player = Players:FindPlayerFromCharacter(hit.Parent) -- making the player a varaible
wait(certainAmount) -- waiting a certain amount
Player:Kick(Reason) -- kicking player
end
end
end)

make sure to tell if the script has an error since i made it without any checks also if you want to kick without any reason in Player:Kick(Reason) remove the "Reason"

Ad

Answer this question