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

could someone help me kick player1 when there is a wrong code given? [not so serious]

Asked by 6 years ago

am tryin to make a login screen so when you input wrong password it kicks you off of the game. what i have done so far in localscript.

local code = script.Parent.Parent.Code
local textbox = script.Parent.Parent.password


script.Parent.MouseButton1Click:Connect(function()
    if textbox.Text == code.Value then
        script.Parent.Text = 'Welcome to [UnnAmeD]'
        wait(2)
        script.Parent.Text = 'have a nice day [remember to read rules]'
        wait(4)
        script.Parent.Parent.Visible = false
    else
        script.Parent.Text = 'Incorrect code'
        wait(2)
        script.Parent.Text = 'please leave'
    end
end)

[image]

explorer

1 answer

Log in to vote
0
Answered by
iladoga 129
6 years ago

This is in fact very easy and you can do this from server or client. In this case we can kick the player using the local script because we are kicking the client that the code is on so there are no problems. But for kicking other players you will need to use remote events.

    local code = script.Parent.Parent.Code
    local textbox = script.Parent.Parent.password
    local plr = game:GetService("Players").LocalPlayer


    script.Parent.MouseButton1Click:Connect(function()
        if textbox.Text == code.Value then
            script.Parent.Text = 'Welcome to [UnnAmeD]'
            wait(2)
            script.Parent.Text = 'have a nice day [remember to read rules]'
            wait(4)
            script.Parent.Parent.Visible = false
        else
            script.Parent.Text = 'Incorrect code'
            wait(2)
        plr:Kick("Your code is incorrect!")
        end
    end)

Enjoy your day and if you have any problems please contact me

0
is it possible to delete the textbox(password) in that same "incorrect password" thingy? aaro102 7 — 6y
0
yes just add: textbox.Active = false and textbox.Visible = false or textbox:Destroy() your choice iladoga 129 — 6y
0
thx aaro102 7 — 6y
Ad

Answer this question