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

This script does not clone to the PlayerGui instead stays in replicated storage?

Asked by 5 years ago

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)
0
Change line 16, adding just 'player' in the parameters and if that doesn't work, also add just 'player' in the parameters for line 3 of your localscript, hope this helps. TheOnlySmarts 233 — 5y
0
Does not seem to work idk why WillBe_Stoped 71 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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.

0
Does not work :( i tried adding "addPlayer" WillBe_Stoped 71 — 5y
0
your suppose to define it User#23365 30 — 5y
0
it is DEFINED EXPODO WASSUP ITS WILLBE LOL WillBe_Stoped 71 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
0
No this wouldn't be helpful because you can't do FireClient and change it to OnServerEvent, and this also wouldn't be a good way of doing this because it will show everyone in the server the Players Score, and if most of those Players are in a Minigame or something and a big GUI pops up, middle game, then obviously they'd get mad and leave. But good try though. TheOnlySmarts 233 — 5y

Answer this question