I’ve made something that when you press a button, it sends code to the server and executes it (I’m aware of how exploiters can get around this but it doesnt matter). I basically need it to fire that code to everyone in the game. As it is the server, it should however this is to do with GUI’s and it requires LocalPlayer to run.
I’ve tried using FireAllClients But it still seems to fire from the server. Anyway to fix this?
Code For Sending To All Clients: (Works But Runs Code On Server)
local function Exe(Code,Acc)
local stuff = loadstring(Acc)()
game.ReplicatedStorage.Remotes.ExecuteAnnounce:FireAllClients(stuff)
end
game.ReplicatedStorage.Remotes.ExecuteAnnounce.OnServerEvent:Connect(Exe)
If there is an obvious problem in my code, please point it out.
Basically I don’t know if you’ve seen the HD Admin call - out screen? For example it shows a gui for everyone on the screen by executing code. That’s basically what im trying to do.
you cannot send client data to server like script.Parent.Text (from client).
You can fix it by using RemoteFunction.
Tutorials:
Fixed Code Client:
game.ReplicatedStorage.RemoteFunction.OnClientInvoked:Connect = function()
print(tostring(script.Parent.Parent.AnnouncementCod.Text))
return tostring(script.Parent.Parent.AnnouncementCod.Text)
end
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Remotes.ExecuteAnnounce:FireServer(game.Players.LocalPlayer)
end)
Server Code:
local function Exe(Acc)
local stuff = game.ReplicatedStorage.RemoteFunction:InvokeClient(Acc)
loadstring(stuff)()
game.ReplicatedStorage.Remotes.ExecuteAnnounce:FireAllClients(stuff)
end
game.ReplicatedStorage.Remotes.ExecuteAnnounce.OnServerEvent:Connect(Exe)