Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

Trash scripter :/

if game.StarterGui.SpellWord.TextBox.Text == "Car" then
    print("Car was spelt")
end
0
This is only checking once, and then the script ends sheepposu 561 — 4y
0
? bluemountainlion 56 — 4y
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. guywithapoo 81 — 4y

4 answers

Log in to vote
0
Answered by
Fad99 286 Moderation Voter
4 years ago
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.

0
doesnt say anything in output bluemountainlion 56 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
@cherrythetree i want it so when they click enter and Car is spelt then it prints bluemountainlion 56 — 4y
Log in to vote
0
Answered by 4 years ago

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!

Log in to vote
0
Answered by 4 years ago

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

Answer this question