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

If statements. If TextBox text is the same as a player name then give tool?

script.Parent.Send.MouseButton1Click:connect(function() --Click
	if script.Parent.PlayerName.Text[game.Players] then --If text = a player
		if game.Players[script.Parent.PlayerName.Text].Backpack:FindFirstChild("Ticket") == nil then --if the player hasn't got the tool already
			if script.Parent.PlayerClass.Text == "Eco" then --If the 2nd textBox's text is Eco, then
				local clone = game.ReplicatedStorage.Ticket:Clone() 
				clone.Parent = game.Players[script.Parent.PlayerName.Text].Backpack --Clone
				clone.Handle.BrickColor = BrickColor.new("Deep blue") --Change the tool's color
				script.Parent.Send.Visible = false --Disable the button
				wait(10) 
				script.Parent.Send.Visible = true --Enable the button
			elseif script.Parent.PlayerClass.Text == "Pro" then --If the 2nd textBox's text is Pro, then
				local clone = game.ReplicatedStorage.Ticket:Clone() 
				clone.Parent = game.Players[script.Parent.PlayerName.Text].Backpack
				clone.Handle.BrickColor = BrickColor.new("Deep orange")
				script.Parent.Send.Visible = false
				wait(10)
				script.Parent.Send.Visible = true
			end
		end
	end
end)

There aren't any errors, and I do meet all the conditions. Yes, I did write this code. I'm just adding those comments as it does get a little confusing.

1 answer

✓ Accepted answer

The issue is with your second line. What you wrote checks if the Players service is in the Text, which is impossible.

if game.Players:FindFirstChild(script.Parent.PlayerName.Text) then

The above line will check if the text specified is equal to any player.

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