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

Event not working?

It is a simple UI effect, that searches through frames to find a certain text label, once the mouse hovers over the text label, it causes an effect to occur.

The effect works for the first 2 Frames, but the last one doesn't seem to work, the actual event doesn't even occur.

This is in a local script. All 3 frames are similar, including the children of them, only difference is the Y Scale of the frames. Works in Play mode, but in Server Test it does not.

local Stats = script.Parent
local Player = game.Players.LocalPlayer

for i,v in pairs (Stats:GetChildren()) do
	if v:IsA("Frame") and v.Name ~= ("HelpText") then
		for i, ChildrenofV in pairs (v:GetChildren()) do
			if ChildrenofV.Name == ("H") or ChildrenofV.Name == ("E") or ChildrenofV.Name == ("M") then
				local Hide = ChildrenofV.Parent:WaitForChild("Hider")
				
					ChildrenofV.MouseEnter:connect(function() --- Mouse Over Effect
						print(ChildrenofV)
						Hide:TweenSizeAndPosition(UDim2.new(.1,0,.8,9), UDim2.new(8.4,0,Hide.Position.Y.Scale,0), "Out", "Quad", .35, true)
					wait(.4)
						while Hide.Position == UDim2.new(8.4,0,Hide.Position.Y.Scale,0) do
							repeat
								Hide.Parent:FindFirstChild("Bar").BackgroundColor3 = Color3.new(76/255, 100/255, 130/255)
							wait(.3)
								Hide.Parent:FindFirstChild("Bar").BackgroundColor3 = Color3.new(57/255, 74/255, 97/255)
							wait(.3)
							until
								Hide.Position == UDim2.new(1,0,Hide.Position.Y.Scale,0)
						end
					end)

1 comment

0

Lines 4-11 is where I believe the problem is at.

1 answer

Try this:

for _, frame in pairs (Stats) do -- Gets the children of stats
	if frame:IsA'Frame' and frame.Name ~= 'HelpText' then -- Makes sure it is a frame and it is not named "HelpText"
		for _, children in pairs (frame:GetChildren()) do -- Get's the children of the frame
			children.MouseEnter:connect(function() -- All of the children of the frame will play an effect when the mouse is hovered over it.
				if children.Name == "M" or children.Name == "E" or children.Name == "H" then
					-- effect here
				end
			end)
		end
	end
end

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