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
local UIS = game:GetService("UserInputService") local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local Erase = script.Parent.Parent:WaitForChild("Erase") local Send = script.Parent.Parent:WaitForChild("Send") local point = script.Parent:FindFirstChild("Pointer") local canvas = script.Parent local hold = false function paint(X, Y) local gui_X = canvas.AbsolutePosition.X local gui_Y = canvas.AbsolutePosition.Y local offset = Vector2.new(math.abs(X - gui_X), math.abs(Y - gui_Y - 36)) point.Position = UDim2.new(0, offset.X, 0 , offset.Y) if hold == false then return end local pixel = point:Clone() pixel.Name = "Pixel" pixel.Parent = canvas end Erase.MouseButton1Click:Connect(function() local children = canvas:GetChildren() for i, child in pairs(children) do if child.Name == "Pixel" then child:Destroy() end end end) canvas.MouseMoved:Connect(paint) canvas.MouseEnter:Connect(function() point.Visible = true end) canvas.MouseLeave:Connect(function() point.Visible = false end) UIS.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then hold = true end end) UIS.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then hold = false end end) --script.Parent.Parent, player.Name Send.MouseButton1Click:Connect(function(player) game.ReplicatedStorage.RemoteEvents.ShareEvid:FireServer(player) script.Parent.Parent.Draw.Visible = false script.Parent.Parent.Send.Visible = false script.Parent.Parent.Erase.Visible = false script.Parent.Top.Visible = false end) game.ReplicatedStorage.RemoteEvents.ShareEvid.OnClientEvent:Connect(function(player) local Gui = plr.PlayerGui.Evidence.Draw:Clone() Gui.Top.Text = plr.Name.."'s Evidence" Gui.Parent = player return Gui end)
Yes,it is a canvas GUI.
Server
game.ReplicatedStorage.RemoteEvents.SetOrder.OnServerEvent:Connect(function() local Teams = game.Teams for i, v in pairs(Teams.Innocent:GetPlayers()) do local Char = v.Character Char.HumanoidRootPart.CFrame = workspace.InnoTP.CFrame end for i, v in pairs(Teams.Blamed:GetPlayers()) do local Char = v.Character Char.HumanoidRootPart.CFrame = workspace.BlameTP.CFrame end workspace.Separate.CanCollide = true wait(8) workspace.Separate.CanCollide = false end) --The part up is another thing,recommend to not pay attention to it game.ReplicatedStorage.RemoteEvents.ShareEvid.OnServerEvent:Connect(function(player) for _, player in pairs(game:GetService("Players"):GetPlayers()) do game.ReplicatedStorage.RemoteEvents.ShareEvid:FireClient(player) end end)
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.
this is the change to the serverscript starting at line 20
game.ReplicatedStorage.RemoteEvents.ShareEvid.OnServerEvent:Connect(function(players) for _, player in pairs(game:GetService("Players"):GetPlayers()) do game.ReplicatedStorage.RemoteEvents.ShareEvid:FireAllClients(player) end end)
p.s I hope this helped this i signed up just to answer this question so this is my first post.
First, in your Server Script, instead of Firing Clients separately, you can Fire all clients at once:
game.ReplicatedStorage.RemoteEvents.ShareEvid:FireAllClients()
And the line above it, where server is receiving, you can do:
game.ReplicatedStorage.RemoteEvents.ShareEvid.OnServerEvent:Connect(function(plr)
And on line 67, I assume you are using:
game.ReplicatedStorage.RemoteEvents.ShareEvid.OnClientEvent:Connect(function(player)
Instead, you can simply do:
game.ReplicatedStorage.RemoteEvents.ShareEvid.OnClientEvent:Connect(function()
Then, you can make the Local Player the parent of the Gui:
Gui.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:
game.ReplicatedStorage.RemoteEvents.ShareEvid.OnClientEvent:Connect(function() local Gui = plr:WaitForChild("PlayerGui").Evidence.Draw:Clone() Gui.Parent = plr:WaitForChild("PlayerGui") Gui.Top.Text = plr.Name.."'s Evidence" return Gui end)
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:
-- Make an empty Screen Gui and name it CanvasToAll --Local script for button local player = game.Players.LocalPlayer local canvas = player:WaitForChild("PlayerGui").CanvasGui:GetChildren() -- It will get contents from the Gui local canvasG = player:WaitForChild("PlayerGui").CanvasGui script.Parent.MouseButton1Click:Connect(function() if game.ReplicatedStorage.CanvasBool.Value == true then game.ReplicatedStorage.CanvasR:FireServer(canvas) end end) game.ReplicatedStorage.CanvasR.OnClientEvent:Connect(function(canvasC) for i, v in pairs(canvasC) do local clone = v:Clone() clone.Parent = canvasG end end) -- Server script in ServerScriptService game.ReplicatedStorage.CanvasR:OnServerEvent:Connect(function(plr, canvas) game.ReplicatedStorage.CanvasBool.Value = true if game.ReplicaredStorage.CanvasBool.Value == true then for i, v in pairs(canvas) do local clone = v:Clone() clone.Parent = game.ReplicatedStorage.Canvas -- Made a folder in ReplicatedStorage called Canvas end wait(1) local canvasContents = game.ReplicatedStorage.CanvasR:GetChildren() game.ReplicatedStorage.CanvasR:FireAllClients(canvasContents) game.ReplicatedStorage.CanvasBool.Value = false end end) -- Added CanvasBool as a bool value to prevent overlapping if button is pressed simultaneously by two or more players Hope it helps! Lemme know.