So in my script below, the UIButton can only be accessed to those who are teamed on host. When I test my game, team myself Host than refresh myself. The button is there, but when I press the button, the script doesn’t execute. I am not sure why and need some help.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ToggleUI = ReplicatedStorage.ToggleUI
local Player = game.Players.LocalPlayer
local CaptainList = Player:WaitForChild("PlayerGui"):WaitForChild("CaptainList")
local UIButton = Player:WaitForChild("PlayerGui"):WaitForChild("SendCaptainScreenGui").SendCaptain
UIButton.MouseButton1Up:Connect(function()
ToggleUI:FireServer()
end)
ToggleUI.OnClientEvent:Connect(function()
for _, descendant in pairs(CaptainList:GetDescendants()) do
if descendant:IsA("TextBox") or descendant:IsA("ScrollingFrame") or descendant:IsA("TextButton") then
descendant.Visible = true
else
print("Ignore")
end
end
end)