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

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

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

✓ Accepted answer

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

3 comments

0

is it possible to delete the textbox(password) in that same "incorrect password" thingy?

0

yes just add: textbox.Active = false and textbox.Visible = false or textbox:Destroy() your choice

0

thx

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