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

Script will not execute, no error, modify Text?

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

✓ Accepted answer

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)

2 comments

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.

0

Thank you, I've been looking at this wrong. I'm still a little new at scripting with GUIs.

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