the script runs before the imagebutton enters slots.. it skips function MouseHover()
local gui = script.Parent local slots = gui.Frame.ScrollingFrame.FrameH local hats = slots:GetChildren() local item = gui.Frame.item function findfirstchild(slots) if slots.Name == "a1" then for i = 1,#hats do hats[i].MouseEnter:connect(function() function MouseHover() wait() item.ImageLabel.Image = "http://www.roblox.com/Thumbs/Asset.ashx?format=png&width=420&height=420&assetId="..hats[i].id.Value.."" MouseHover() end print("successful") end) end end end
All you need to do is get rid of the new function MouseHover except for the item.ImageLabel.Image line, you're trying to call the function inside the function with your script.
In your script it was going like this.
function Msg() print("Hi") Msg() end --The script is only reading this part.
local gui = script.Parent local slots = gui.Frame.ScrollingFrame.FrameH local hats = slots:GetChildren() local item = gui.Frame.item function findfirstchild(slots) if slots.Name == "a1" then for i = 1,#hats do hats[i].MouseEnter:connect(function() item.ImageLabel.Image = "http://www.roblox.com/Thumbs/Asset.ashx?format=png&width=420&height=420&assetId="..hats[i].id.Value.."" print("successful") end) end end end