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

error with gui local script ?

OUTPUT:01:15:43.903 - Attempt to connect failed: Passed value is not a function 01:15:43.908 - Script 'Players.Player.PlayerGui.ScreenGui.test', Line 35 01:15:43.909 - Stack End 01:15:43.909 - Players.Player.PlayerGui.ScreenGui.test:36: attempt to call global 'MouseHover' (a nil value) 01:15:43.912 - Stack Begin 01:15:43.914 - Script 'Players.Player.PlayerGui.ScreenGui.test', Line 36 01:15:43.914 - Stack End 01:15:50.275 - attempt to call a nil value 01:15:50.278 - Disconnected event because of exception

 local gui = script.Parent
local item = gui.Configuration
local slots = gui.Frame.ScrollingFrame.FrameI

local P = game.Players.LocalPlayer;
repeat wait() until P.Character;
local C = P.Character;
local hats = slots:GetChildren()
for i = 1,#hats do
	
function MouseHover()
	hats[i].MouseEnter:connect(function()
wait()
item.hat.Text = "http://www.roblox.com/Thumbs/Asset.ashx?format=png&width=420&height=420&assetId="..hats[i].id.Value..""
item.Title.Text = hats[i].TextLabel.Text
item.id.Value = hats[i].id.Value
end
MouseHover()
print("successful")
	end)
end


function list()
	gui.Frame.item.id.Text = item.id.Value
	gui.Frame.item.Title.Text = item.Title.Text
	gui.Frame.item.ImageLabel.Image = item.hat.Text
end

for i = 1,#hats do
	hats[i].MouseButton1Up:connect(function()
list()
	end)
end
slots.ChildAdded:connect( MouseHover )
MouseHover()

script works fine when everything is loaded but this is an inventory so when i buy a hat it goes to the inventory but cant click it and mousehover isnt working... the hat i hover over on other tab works with same script

1 answer

✓ Accepted answer

I believe I fixed it. But I don't know without seeing the GUI and testing it.

local gui = script.Parent
local item = gui.Configuration
local slots = gui.Frame.ScrollingFrame.FrameI
 
local P = game.Players.LocalPlayer;
repeat wait() until P.Character;
	local C = P.Character;
	local hats = slots:GetChildren()
	for i = 1,#hats do
		function MouseHover()
				hats[i].MouseEnter:connect(function()
				wait()
				item.hat.Text = "http://www.roblox.com/Thumbs/Asset.ashx?format=png&width=420&height=420&assetId="..hats[i].id.Value..""
				item.Title.Text = hats[i].TextLabel.Text
				item.id.Value = hats[i].id.Value
			end)
		end
		MouseHover()
		print("successful")
end

function list()
    gui.Frame.item.id.Text = item.id.Value
    gui.Frame.item.Title.Text = item.Title.Text
    gui.Frame.item.ImageLabel.Image = item.hat.Text
end
 
for i = 1,#hats do
	hats[i].MouseButton1Up:connect(function()
		list()
	end)
end
slots.ChildAdded:connect(MouseHover)
MouseHover()

3 comments

0

still says same output bcuz when script runs there in nothing in the frame once i buy the hat then a button goes into the frame

0

had to create childadded function to refresh the script

0

Did that fix it?

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