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.

01local code = script.Parent.Parent.Code
02local textbox = script.Parent.Parent.password
03 
04 
05script.Parent.MouseButton1Click:Connect(function()
06    if textbox.Text == code.Value then
07        script.Parent.Text = 'Welcome to [UnnAmeD]'
08        wait(2)
09        script.Parent.Text = 'have a nice day [remember to read rules]'
10        wait(4)
11        script.Parent.Parent.Visible = false
12    else
13        script.Parent.Text = 'Incorrect code'
14        wait(2)
15        script.Parent.Text = 'please leave'
16    end
17end)

[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.

01local code = script.Parent.Parent.Code
02local textbox = script.Parent.Parent.password
03local plr = game:GetService("Players").LocalPlayer
04 
05 
06script.Parent.MouseButton1Click:Connect(function()
07    if textbox.Text == code.Value then
08        script.Parent.Text = 'Welcome to [UnnAmeD]'
09        wait(2)
10        script.Parent.Text = 'have a nice day [remember to read rules]'
11        wait(4)
12        script.Parent.Parent.Visible = false
13    else
14        script.Parent.Text = 'Incorrect code'
15        wait(2)
16    plr:Kick("Your code is incorrect!")
17    end
18end)

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