Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i can share a GUI to all clients?

Asked by 4 years ago

Hello,just for further info,this is an alt account i used because i didnt remember my password on my main acc.

So,I was trying to make a player when it clicks on a GUI button,it creates a clone of it and passes it to all players in the server.I havent figured it out yet and its driving me crazy! Also tried some dev forum solutions,still nothing.

I have tested it out with a binable event and remote event (Not sure if i need to use a Remote Function) In the binable event,it works,but it only appears to the player who pressed it

I am using a remote event:

Local

01local UIS = game:GetService("UserInputService")
02 
03local plr = game.Players.LocalPlayer
04local mouse = plr:GetMouse()
05 
06local Erase = script.Parent.Parent:WaitForChild("Erase")
07local Send = script.Parent.Parent:WaitForChild("Send")
08local point = script.Parent:FindFirstChild("Pointer")
09local canvas = script.Parent
10 
11local hold = false
12 
13function paint(X, Y)
14    local gui_X = canvas.AbsolutePosition.X
15    local gui_Y = canvas.AbsolutePosition.Y
View all 76 lines...

Yes,it is a canvas GUI.

Server

01game.ReplicatedStorage.RemoteEvents.SetOrder.OnServerEvent:Connect(function()
02    local Teams = game.Teams
03 
04    for i, v in pairs(Teams.Innocent:GetPlayers()) do
05        local Char = v.Character
06        Char.HumanoidRootPart.CFrame = workspace.InnoTP.CFrame
07    end
08 
09    for i, v in pairs(Teams.Blamed:GetPlayers()) do
10        local Char = v.Character
11        Char.HumanoidRootPart.CFrame = workspace.BlameTP.CFrame
12    end
13 
14    workspace.Separate.CanCollide = true
15    wait(8)
View all 24 lines...

And a bonus:Top is not a valid member of ScreenGui? While its parented to the draw frame.

If you could include example code it would be better

Sorry,i am not that good in scripting. Thanks,Have a nice day.

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

this is the change to the serverscript starting at line 20

1game.ReplicatedStorage.RemoteEvents.ShareEvid.OnServerEvent:Connect(function(players)
2for _, player in pairs(game:GetService("Players"):GetPlayers()) do
3game.ReplicatedStorage.RemoteEvents.ShareEvid:FireAllClients(player)
4end
5end)

p.s I hope this helped this i signed up just to answer this question so this is my first post.

0
It didnt worked,still,it shows nothing,but thanks for at least trying yuni_Boy1234 320 — 4y
0
what is the error you are getting? omgcchheeessee 0 — 4y
0
It doesnt print any error yuni_Boy1234 320 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

First, in your Server Script, instead of Firing Clients separately, you can Fire all clients at once:

1game.ReplicatedStorage.RemoteEvents.ShareEvid:FireAllClients()

And the line above it, where server is receiving, you can do:

1game.ReplicatedStorage.RemoteEvents.ShareEvid.OnServerEvent:Connect(function(plr)

And on line 67, I assume you are using:

1game.ReplicatedStorage.RemoteEvents.ShareEvid.OnClientEvent:Connect(function(player)

Instead, you can simply do:

1game.ReplicatedStorage.RemoteEvents.ShareEvid.OnClientEvent:Connect(function()

Then, you can make the Local Player the parent of the Gui:

1Gui.Parent = plr:WaitForChild("PlayerGui")

I assume the Gui is already present in Starter Gui. This is how your end part of Local script moght look:

1game.ReplicatedStorage.RemoteEvents.ShareEvid.OnClientEvent:Connect(function()
2        local Gui = plr:WaitForChild("PlayerGui").Evidence.Draw:Clone()
3        Gui.Parent = plr:WaitForChild("PlayerGui")
4        Gui.Top.Text = plr.Name.."'s Evidence"
5 
6        return Gui
7end)

If it doesn't work, lemme know the errors.

Please Upvote and lemme know if it helped!

Edit: You told me that a player draws something on Canvas, so it shows on every player's Gui.

It's just an eg, which does not represent your script in any way. Take the idea from here, and implement it in your game.

for that, u can do:

01-- Make an empty Screen Gui and name it CanvasToAll
02 
03--Local script for button
04local player = game.Players.LocalPlayer
05local canvas = player:WaitForChild("PlayerGui").CanvasGui:GetChildren() -- It will get contents from the Gui
06local canvasG = player:WaitForChild("PlayerGui").CanvasGui
07 
08script.Parent.MouseButton1Click:Connect(function()
09    if game.ReplicatedStorage.CanvasBool.Value == true then
10        game.ReplicatedStorage.CanvasR:FireServer(canvas)
11    end
12end)
13 
14game.ReplicatedStorage.CanvasR.OnClientEvent:Connect(function(canvasC)
15    for i, v in pairs(canvasC) do
View all 39 lines...
0
Didnt work,still it show nothing,and no error is shown on the output,but thanks for trying! yuni_Boy1234 320 — 4y
0
Can you add prints before and after firing remote events? I doubt there's something to be in Remote Event only BestCreativeBoy 1395 — 4y
0
Hmm... I have added them,they all print when i click the send button yuni_Boy1234 320 — 4y
0
It prints first "I clicked the send button" then "the remote has ran on its server call" and finally "the remote has ran on its client call" yuni_Boy1234 320 — 4y
View all comments (10 more)
0
I assume the Gui is in the starteGui by default, so try removing cloning thing. BestCreativeBoy 1395 — 4y
0
kinda basic stuff but are all of the GUI elements enabled / visible when you're trying to display it? AlexTheCreator 461 — 4y
0
well, you have to check the properties in order to get your answer, but if you are talking about by default, it is eanbled/visible BestCreativeBoy 1395 — 4y
0
Giving more information,a player draws something in the canvas gui,then when it press its send button ,its drawing its showed to all players yuni_Boy1234 320 — 4y
0
I edited my answer, try checking that out! BestCreativeBoy 1395 — 4y
0
Thanks,gonna check if it works later,i am occupied right now yuni_Boy1234 320 — 4y
0
I am confused,i saw the script,does the canvas remote events needs some child or something? yuni_Boy1234 320 — 4y
0
And tried it and still nothing,i can invite you to the roblox studio if you wanna see the objects tho,or i can just tell them yuni_Boy1234 320 — 4y
0
@Samyak7649, this is my discord. DM me there. It will be easier to help you there. BestCreativeBoy 1395 — 4y
0
Sent friend request,or theres other way? yuni_Boy1234 320 — 4y

Answer this question