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

Not giving pet if text is == "TEST"?

So I want then you write a word like TEST it gives you a pet but this script wont work!

local pet = game.Lighting.Pet1:Clone()
local plr = game.Players.LocalPlayer

if script.Parent.Text == "TEST" then
	pet.Parent = plr.Character
end

4 comments

0

Do you mean in chat or gui? Because you write if script.Parent.text == ...

0

in gui

0

Ok but you need locate the gui first ...

0

wdym?

2 answers

✓ Accepted answer

Because this is a TextBox there is no Text by default in the TextBox yet. You most likely want a Changed listener to fire when the text is updated and then compare it to "TEST".

2 comments

0

As the guy above me said -FloweryMonkeyboy5-, I will recommend you using remote events and a Changed function.

0

Correct but could be explained better. Basicly "if" statements check once when they are run, so it will only check the text when the script is run. All instances have an event called Changed, that fires when one of it's attributes change. Use it to run the if statement when text is changed, instead of once.

it might be this one

local pet = game.Lighting.Pet1:Clone()
local plr = game.Players.LocalPlayer
local petplace = plr.Character
local gui = game.StarterGui."Gui Name"

if script.Parent.gui."Frame where is it or button".Text == "TEST" then
	pet.Parent = petplace.Parent
end

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