Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

2 comments

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.

0

Does not seem to work idk why

2 answers

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.

3 comments

0

Does not work :( i tried adding "addPlayer"

0

your suppose to define it

0

it is DEFINED EXPODO WASSUP ITS WILLBE LOL

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)

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.