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

I am trying to get an animated text gui to pop up when I click a brick. What am I doing wrong?

It's basically someone talking when I click a bell. Picture of my code:https://ibb.co/QfZLJWn I have a click detector as the child of the brick I want to press, and this Script as the child of the TextLabel that will pop up. Anything I'm doing wrong? If you have any questions DM me at rebloom#9167. Thanks.

1 comment

0

Id say using events and having them run would probably have it work how you want if I am understanding your question correctly.

1 answer

✓ Accepted answer

From what I see, you don't assign the ClickDetector.MouseClick event to a function. The common way is to simply do

ClickDetector.MouseButton.MouseClick:Connect(function(playerWhoClicked)
	TextLabel = script.Parent
	local Text
	function soundEffect()
		local sound = Instance.new("Sound")
		sound.Parent = ClickDetector.Parent
		sound.Name = "Text Sound"
		sound.Volume = 1
		sound:Play()
		game.Debris:AddItem(sound, sound.TimeLength) --Deletes the sound after it stops playing
	end)
	function setText(word)
		Text = word
	end

	for i = 1, #Text do
		TextLabel.Text = string.sub(Text, 1, i)
		soundEffect()
		TextLabel.Color3 = Color3.fromRGB(0, 0, 0)
		if script.Parent.Parent.Parent.Enabled then
			local frame = script.Parent.Parent
			frame.Visible = true
			wait(0.04)
		end
	end
	wait(3)
	setText("Good Evening")
	wait(3)
	setText("What can I do for ye?")
	print("Done")
end)

If you're waiting for the event to happen, you'd write

ClickDetector.MouseClick:Wait()
--code here

2 comments

0

Utter_Incompetence, still doesn't run. What am I doing wrong? https://ibb.co/PxfNHqB

0

You gotta put the code inside the function!

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