All of a sudden my event are replacing the 2nd arg (argument) with the 1st
Client Gui Script:
for _,Button in pairs (Main.GuiManager.TestButtons:GetDescendants()) do
if Button:IsA("TextButton") then
Button.MouseButton1Click:Connect(function() -- Event per button
if not Clicked and Button.Active == true then -- Button debounce
Clicked = true
print(player, Button)
TPWC:InvokeServer(player,Button)
RunService.Heartbeat:Wait()
Clicked = false
end
end)
end
end
for _,Button in pairs (tppanel.Main.GuiManager.TestButtons:GetDescendants()) do
if Button:IsA("TextButton") then
Button.MouseButton1Click:Connect(function() -- Event per button
if not Clicked and Button.Active == true then -- Button debounce
Clicked = true
print(player, Button)
TPWC:InvokeServer(Button) <- Removed "player,"
RunService.Heartbeat:Wait()
Clicked = false
end
end)
end
end
Passing the name worked, however I need the instance of the button and not just the name. Maybe there’s a way to scan the gui from the server for mouse inputs instead of the client?
Why are you using a RemoteFunction for that if you’re not wanting to retrieve something? Convert it to a RemoteEvent, although the Button may not still be detected. What’s in the code for the OnServerInvoke?
It’s for if the player is at the place they want to go to, it would invoke back to the client from the server to create some text telling them that they are there
TPWC.OnServerInvoke = function(player,Button)
print(player,Button)
local ButtonName = tostring(Button.Parent.Parent.Name) -- Get World name
for _,Maps in pairs (game.Workspace.Map:GetChildren()) do -- Get current maps
if tostring(Maps) == ButtonName then -- TpPos == ButtonMap
if tostring(Maps) == player.BPack.CurrentWorld.Value then -- Player is in world
TPWC:InvokeClient(player,Button)
else
TP(player,Maps)
TPWC:InvokeClient(player)
end
end
end
end
ClientInvoke:
TPWC.OnClientInvoke = function(Button)
if Button then
-- Save current colors --
table.insert(Color,Button.BackgroundColor3)
table.insert(Color,Button.Parent.BackgroundColor3)
table.insert(Words,Button.Text)
-- Set Error --
Button.BackgroundColor3 = Color3.fromRGB(163,163,163)
Button.Parent.BackgroundColor3 = Color3.fromRGB(79,79,79)
Button.TextColor3 = Color3.fromRGB(0,0,0)
Button.Text = "That's here!"
wait(2)
-- Revert --
Button.BackgroundColor3 = Color[1]
Button.Parent.BackgroundColor3 = Color[2]
Button.TextColor3 = Color3.fromRGB(255,255,255)
Button.Text = Words[1]
-- Garbage Collection --
table.clear(Color)
table.clear(Words)
else
Exit()
end
end