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

Script will not execute, no error, modify Text?

Asked by
bloxxyz 274 Moderation Voter
9 years ago

I need help, as I am absolutely lost. I am getting no error, the entire script works except for this one single line, almost as if ROBLOX is ignoring it for some reason. It's painfully confusing and I feel maybe it's just where I put the line or perhaps I wasn't specific enough? If anyone can help, thank you.

The script is inside of a Part, and when you click it a GUI appears. That works fine, but it doesn't modify the Text of the other GUI.

Here is the script, and below that is what my explorer looks like:

CODE:

curobject1 = game.StarterGui.CurrentObjective.Frame.Textstuff
script.Parent.ClickDetector.MouseClick:connect(function(plr)
    curobject1.Text = "CURRENT OBJECTIVE: Find the note." --This line being ignored
    print("Reading note")
    intclone:Destroy()
    local letterclone = game.Lighting.LetterOpened:Clone()
    letterclone.Parent = plr.PlayerGui

end)

EXPLORER: http://i.imgur.com/T37ScP3.jpg

Thanks guys. Appreciate it.

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

It's not being ignored, it's just that StarterGui isn't where the guis that you see are stored. They're stored in your player's PlayerGui - so you should search for the gui from the player's PlayerGui.


script.Parent.ClickDetector.MouseClick:connect(function(plr)
    --Define the gui from their PlayerGui
    local curobject1 = plr.PlayerGui.CurrentObjective.Frame:FindFirstChild('TextStuff')
    --Make sure it's there, so the script doesn't return an error if it's not there.
    if curobject1 then
        curobject1.Text = "CURRENT OBJECTIVE: Find the note."
        print("Reading note")
        intclone:Destroy()
        local letterclone = game.Lighting.LetterOpened:Clone()
        letterclone.Parent = plr.PlayerGui
    end
end)
0
`curobject1` will always pass the condition, since it's a ROBLOX object. If it didn't exist, you would have just gotten an error on line 3. BlueTaslem 18071 — 9y
0
Thank you, I've been looking at this wrong. I'm still a little new at scripting with GUIs. bloxxyz 274 — 9y
Ad

Answer this question