local script inside text box, no errors in output and it will not clone the pet inside player character after the text inside text box is test
local pet = game.ReplicatedStorage:WaitForChild("Pet") local player = game.Players.LocalPlayer local char = player.Character or player.CharacterAdded:wait() local text = script.Parent if text.Text == "test" then local clone = pet:Clone() clone.Parent = char end
Like Kingdom5 said, your code was only going to run once since there was nothing calling it except your GUI loading. That's fine if that was your intention, but otherwise, you'll need an event to fire every time you type in that text box to re-run your code.
local pet = game.ReplicatedStorage:WaitForChild("Pet") local player = game.Players.LocalPlayer local Character = player.Character or player.CharacterAdded:wait() local TextBox = script.Parent local Keyword = 'test' -- On Text Changed compare live TextBox:GetPropertyChangedSignal('Text'):Connect(function() -- If you don't want the player to mass spawn pets local HasPet = Character:FindFirstChild(pet.Name) -- Compare Keyword with TextBox.Text if TextBox.Text == Keyword and not HasPet then -- Clone Pet to Character if they match pet:Clone().Parent = Character end) end