I need to make a local button that shows up on one person’s gui clone a TextLabel onto a global gui using a Script, LocalScript, and RemoteEvent.
LocalScript vvv
local btn = script.Parent
local frame = btn.Parent.Parent.Parent.Parent.Frame
local plr = game.Players.LocalPlayer
local label = script.Parent.Parent
local event = script.Parent.Parent.Parent.Parent.Event
btn.MouseButton1Click:Connect(function()
frame:TweenPosition(UDim2.new(0.5, 0, 0.05, -20), nil, Enum.EasingStyle.Sine, 2)
wait(4)
frame:TweenPosition(UDim2.new(0.5, 0, 0.05, -150), nil, Enum.EasingStyle.Sine, 2)
end)
function fire()
event:FireServer(btn.Parent.Text, btn)
end
btn.MouseButton1Click:Connect(fire)
Script vvv
local event = script.Parent.Event
local plr = game.Players.LocalPlayer
local gui = game.StarterGui.staffGui.staffFrame.ScrollingFrame
event.OnServerEvent:Connect(function(plr, text)
for i,v in pairs(game.Players:GetChildren()) do --this is to do this for everyone.
gui.Order:Clone()
end
end)
local event = script.Parent.Event
local plr = game.Players.LocalPlayer
local gui = game.StarterGui.staffGui.staffFrame.ScrollingFrame
event.OnServerEvent:Connect(function(plr, text)
for i,v in pairs(game.Players:GetChildren()) do --this is to do this for everyone.
local clone = gui.Order:Clone()
clone.Parent = gui
end
end)
if this is a local script, don’t use onserverevent, also if it’s a server script, don’t use game.Players.LocalPlayer because the player can only be found on local scripts
local plrs = game:GetService("Players")
local prl = plrs.LocalPlayer
local gui = script:FindFirstAncestorWhichIsA("ScreenGui")
local frame = gui:FindFirstChildWhichIsA("Frame", true)
local event = gui:FindFirstChildWhichIsA("RemoteEvent", true)
local label = gui:FindFirstChildWhichIsA("TextLabel", true)
local button = gui:FindFirstChildWhichIsA("TextButton", true)
button.MouseButton1Click:Connect(function()
frame:TweenPosition(UDim2.new(0.5, 0, 0.05, -20), nil, Enum.EasingStyle.Sine, 2)
task.wait(4)
frame:TweenPosition(UDim2.new(0.5, 0, 0.05, -150), nil, Enum.EasingStyle.Sine, 2)
event:FireServer(label.Text)
end)
local players = game:GetService("Players")
local serverService = game:GetService("ServerScriptService")
local event = serverService:FindFirstChildWhichIsA("RemoteEvent")
local order = serverService:FindFirstChild("Order", true) --move the guiobject named order to the serverscriptservice with the script and remoteevent
event.OnServerEvent:Connect(function(plr, text)
for _, player in ipairs(players:GetPlayers()) do
local clone = order:Clone()
clone.Parent = player:FindFirstChildOfClass("PlayerGui"):FindFirstChildWhichIsA("ScreenGui") --add further instance references here if necessary
end
end)
Would be easier if we knew the Gui structure (order of GuiObject instances).