Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my Kick GUI not working correctly? What did I do wrong?

Hello! Today I made a GUI Kick. The script is not working though. Does anybody know why? Please tell me.

function onClick()
	KickPerson = script.Parent.Parent.PlayerName.Text
	game.Players.KickPerson:Kick()
end

script.Parent.MouseButton1Down:connect(onClick)

1 answer

✓ Accepted answer

Hello, 00o0o0o000o0!

Your code is trying to a player named KickPerson as a child of game.Players, you need to make this in order to use it as variable:

function onClick()
    KickPerson = script.Parent.Parent.PlayerName.Text
    if (game.Players:FindFirstchild(KickPerson)) then -- Checks if user exists/is connected
        game.Players:FindFirstchild(KickPerson):Kick() -- This uses KickPerson as being a variable
    end
end

script.Parent.MouseButton1Down:connect(onClick)

4 comments

0

Ok lemme test out.

0

Script 'Players.Player2.PlayerGui.GUI.Frame.Kick.Kick', Line 3 - function onClick.

0

Script 'Players.Player2.PlayerGui.GUI.Frame.Kick.Kick', Line 3 - function onClick. and Players.Player2.PlayerGui.GUI.Frame.Kick.Kick:3: attempt to call a nil value. Those are in output. Why? It does not work.

1

Try now

This discussion is preserved as it was. New answers, comments, and votes are closed.