I made a script that kicks player if their textlabel has 100, but is not kicking the player.. I need help!

  1. What do you want to achieve? Keep it simple and clear!

I want it to kick the local player if their textlabel text is 100

  1. What is the issue? Include screenshots / videos if possible!

theres no error and is not kicking the player.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried looking for solutions via the devforum and I also google it but I couldn’t find the things related to my problems.

I hope someone could help me with this…
Thank you and have a nice day ahead!

local Fade = game.Players.LocalPlayer.PlayerGui:WaitForChild("Fade")
local Text = script.Parent.Text

if Text == "100" then
    game.Players.LocalPlayer:Kick()
end
1 Like

Try the following workaround:

local Text = script.Parent.Text

if string.find(Text, 100) then
    game.Players.LocalPlayer:Kick()
end
1 Like

it doesn’t work and theres no error in the output :confused:

1 Like

Wait do you want the number to be 100, or the characters to be 100?

1 Like

Is the text initially 100?

local Fade = game.Players.LocalPlayer.PlayerGui:WaitForChild("Fade")
local Text = script.Parent.Text

local function check()
 if Text == "100" then
    game.Players.LocalPlayer:Kick()
  end
end

check()

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
   check()
end)
1 Like

your code seems fine. but to check the error you can change it to a normal script in the
ServerScriptService and do this:

local Fade = game.Players.LocalPlayer.PlayerGui:WaitForChild("Fade")
local Text = script.Parent.Text --[[ here put the textLabel location 
and then add .Text]]
print("check1 - succes")

wait(5)

if Text == "100" then
	print("text is 100!")
	for i, v in pairs(game.Players:GetChildren()) do
		v:Kick()
	end
	print("succes!")
else
	print("text is not 100, text:") 
	print(Text)
end
-- and tell us the output

and tell us the output

The OP doesn’t want to kick all players in game, only the local player.

You can’t reference LocalPlayer in a server script.

I know, but if you want to check what is the error then do this

also what is the fade even do?

because in local scripts print is not working

Alright so there could be multiple issues with this, but I’m gonna have to get assumptions in first.
I’m assuming that

local Fade = game.Players.LocalPlayer.PlayerGui:WaitForChild("Fade")
local Text = script.Parent -- This is the text object (again, assumption)
 
if Text.Text == "100" then
 game.Players.LocalPlayer:Kick()
end

I believe what’s happening is that you’re referencing the Text of the TextLabel once in your script which literally gets you what the text was at that time, what you might need is a function which checks it whenever you require, which can obviously be used with the method I showed above. Or you can use this method also:

local Text = scrit.Parent

local function Check()
 if Text.Text == "100" then
        game.Players.LocalPlayer:Kick()
    end
end

This allows you to use this code multiple lines without redundancy! Anyways, hope this helped.

O0mg, It is workINGG!!! TY SO MUCH!!