So basically what im trying to do is if a admin says ":givescoreboard (player)" it should Clone the gui to the Person. When i Test this script it does everything it clones the GUI to Replicated Storage but it does not clone it to the players GUI afterwards. Why is this? Server Script
local admins = {"dogopvain","RandamuHaise","Player1"} local scoreboardValues = game.Workspace.ScoreboardValues game.Players.PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) if msg:sub(1, 16) == ":givescoreboard " then for i = 1,#admins do if plr.Name == admins[i] then local addPlayer = msg:sub(17, msg:len()) print(addPlayer) if game.Players:FindFirstChild(addPlayer) then local manual = script.ManualGUI:Clone() manual.Parent = game.ReplicatedStorage print("Player has been found") table.insert(admins, addPlayer) game.ReplicatedStorage.GiveScoreBoard:FireClient() else print("Player has not been found") end end end end end) end) game.Players.PlayerAdded:Connect(function(player) local playerGui = player.PlayerGui for i = 1,#admins do if player.Name == admins[i] then local manualGui = script:WaitForChild("ManualGUI") local cloneGuiToPlayer = manualGui:Clone() cloneGuiToPlayer.Parent = playerGui if playerGui:FindFirstChild("ManualGUI") then return end end end end)
Local Script
local rep = game:GetService("ReplicatedStorage") rep.GiveScoreBoard.OnClientEvent:Connect(function() print("Done") if rep:WaitForChild("ManualGui") then local manualGuiClone = rep.ManualGui:Clone() manualGuiClone.Parent = game.Players.LocalPlayer.PlayerGui end end)
If you look at line 16.
game.ReplicatedStorage.GiveScoreBoard:FireClient()
You never specified a client for the server to fire it to!
I notice you get the player on line 9. So use that.
game.ReplicatedStorage.GiveScoreBoard:FireClient(addPlayer)
Don't know why you have a duplicate event listener. You can do it from the same event listener. Also don't use msg:len()
as we have the length operator #
, so #msg
.
Use a server script for player event try doing this
local rep = game:GetService("ReplicatedStorage") rep.GiveScoreBoard.OnServerEvent:Connect(function(plr) print("Done") if rep:WaitForChild("ManualGui") then local manualGuiClone = rep.ManualGui:Clone() manualGuiClone.Parent = plr:WaitForChild('PlayerGui') end end)