Kick On Touch After 15 Seconds

Hi!
I want that when player touched the part, player will get kicked after 15 seconds.
Script:

function onTouch(hit)
	if game.Players:FindFirstChild(hit.Parent.Name) ~= nil then
		local char = game.Players:FindFirstChild(hit.Parent.Name)
		wait(15)
		char:Kick("YOU ESCAPED :D - tutab9")
	end
end

script.Parent.Touched:Connect(onTouch)

But it doesn’t work when I type “wait(15)” into script.
To be honest I don’t know how can I use the wait command with that script:/
Can you help me please(●’◡’●)

is this server kick or client kick

3 Likes

It is just a… Kick. I don’t know:/

1 Like

… is the script server or client

I advise you to look at this :

Hes asking if the script you are using is a LocalScript or a Script. If it’s a LocalScript, I suggest you change it to a Script.

1 Like

You need to use the :Kick() function on the player element, not the character. Also it should be in a server script

1 Like

It’s a script not a local script

1 Like

Can you give an example if you want

1 Like
local function onTouch(hit)
    local character = hit.Parent
    local player = game.Players:GetPlayerFromCharacter(character)

    if player then
        task.wait(10)
        player:Kick("YOU ESCAPED :D - tutab9")
    end
end

script.Parent.Touched:Connect(onTouch)

Bruh man how I didn’t remember the task wait thank you it worked

1 Like

The wait was correct, the issue was basically your logic

Thank you the problem solved I forgot to reply you thanks for suggestion( •̀ ω •́ )✧

She can use it on character aslong as she uses :GetPlayerFromCharacter

1 Like

Thank you so much you can’t know that how I feel now I’m dying for being happy rn✍️(◔◡◔)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.