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

If they spell car why doesn't it print the thing I want it to?

Trash scripter :/

if game.StarterGui.SpellWord.TextBox.Text == "Car" then
	print("Car was spelt")
end

3 comments

0

This is only checking once, and then the script ends

0

?

0

When the game starts this script will instantly run so basically, it will check if anyone has said Car right at the beginning of the game and if no one does then it wont try again.

4 answers

local Box = game.StarterGui.SpellWord.TextBox
Box.Changed:Connect(function(c)
	if c == "Text" then
    		print(Box.Text.." was spelt")
	end
end)

i didint test this out but it should work. The error with your one sheepposu said is the script only checks once and never again but with the .Changed event you can check if it spells something once it changes.

1 comment

0

doesnt say anything in output

Basically, StarterGui is where the place to put ScreenGui at, they replicate to the user's PlayerGui, instead put a LocalScript inside the ScreenGui. Changing something to a ScreenGui in StarterGui will not affect the user's PlayerGui. Note: Please if you didn't understand, put the LocalScript inside the TextBox.

script.Parent.Changed:Connect(function() --TextBox event begins
	if script.Parent.Text == "Car" then --if Car was spelt in the TextBox, then do
		print("Car was spelt!") --success!
	end
end)

Perfect! Changed can also be used when a property of an object is changed. Only Instance who have the Changed event can be used. Example is when Humanoid is damaged. It prints "Damaged!", but this time the event is called "HealthChanged". Put this code in a LocalScript in StarterGear to do so.

local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
player.Character:WaitForChild("Humanoid").HealthChanged:Connect(function()
	print(player.Character:WaitForChild("Humanoid").Health.." is the current health of the user. DAMAGED!")
end)

Rather than using loops, because loops can lag your game when printing so much in the client or server.

1 comment

0

@cherrythetree i want it so when they click enter and Car is spelt then it prints

Here is a script that will make it confirm and print ¨Car was spelt¨ when key ¨;¨ is clicked, you would just have to get the keycode for enter if you wanted that. Put this LocalScript inside ¨SpellWord¨.

UserInput = game:GetService(¨UserInputService¨)
AnswerBox = game.StarterGui.SpellWord[TextBox.Text]

UserInput.InputBegan:Connect(function(Confirm)
       if input.KeyCode == Enum.KeyCode.Semicolon and game.
      print(¨Car was spelt¨!)
end
end)

IF- It does not work, let me know! Haven´t scripted for almost a year!

This should work. I haven’t tested it, but it basically constantly checks to see if the text is car.

while true do
    if game.StarterGui.SpellWord.TextBox.Text == "Car" then
        print("Car was spelt")
    end
end

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