"local script"
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local re = ReplicatedStorage.BookFlight
for i, button in pairs(script.Parent:GetChildren()) do
if button:IsA("TextButton") then
button.MouseButton1Click:Connect(function()
re:FireServer()
end)
end
end
Try this change to your script. I added a print statement inside of the mouse click function, and it prints.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local re = ReplicatedStorage.BookFlight
local button = script.Parent.TextButton
if button:IsA("TextButton") then
button.MouseButton1Click:Connect(function()
re:FireServer()
print("Button Clicked")
end)
end
I also noticed that you are trying to get the players name once the button is clicked. Are you trying to get the players name in the output, or somewhere else?
--local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local re = ReplicatedStorage:WaitForChild("BookFlight")
local button = script.Parent.TextButton
button.MouseButton1Click:Connect(function()
re:FireServer()
print("Button Clicked")
end)
--server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local re = ReplicatedStorage:WaitForChild("BookFlight")
re.OnServerEvent:Connect(function(player)
-- do something
end)