Hi,
I’m just wondering how to make a function that runs when a player clicks the button, but in another script. I thought I knew, but the event is not firing and the function is not running
local plr = game.Players.LocalPlayer
--make transparent
local startGui = game:GetService("StarterGui")
local shippingGui = startGui.delivered.showPath.packet
shippingGui.Visible = false
--delivered is a screen gui, show path a frame, packet an image button
startGui.delivered.showPath.packet.MouseButton1Click:Connect(function() --not triggering
print("Connect") --not printed
end)
You need to get the PlayerGui of the Player not the StarterGui. Try something like this:
local plr = game.Players.LocalPlayer
--make transparent
local startGui = plr:WaitForChild("PlayerGui")
local shippingGui = startGui.delivered.showPath.packet
shippingGui.Visible = false
--delivered is a screen gui, show path a frame, packet an image button
startGui.delivered.showPath.packet.MouseButton1Click:Connect(function() --not triggering
print("Connect") --not printed
end)