Template not Being Cloned ( Server Sided )

I’ve been trying to get a Template to be Clone from ServerStorage with a Server Sided Script, every time a player joins but it seems that the Server Script doesn’t want to Clone the Template. If anyone could help out, that would be great, here’s the script


local list = script.Parent.backgr.Frame.ScrollArea
local Template = game.ServerStorage.Template



local function plrJoined(plr)
	
	if not list:FindFirstChild(plr.Name) then
		
		local plrTemp = Template:Clone()
		plrTemp.Display.Text = plr.DisplayName
		plrTemp.User.Text = plr.Name
		plrTemp.Parent = list
		
		print("test")
		
	end
	
end

local function plrLeft(plrLeft)
	
	if list:FindFirstChild(plrLeft.Name) then
		list:FindFirstChild(plrLeft.Name):Destroy()
	else
		print("Nothing to Remove")
	end
	
end

--------------------------------------------

while wait() do
	
	if game.Players.PlayerAdded then
		plrJoined()
	elseif game.Players.PlayerRemoving then
		plrLeft()
	end
	
end

2 Likes

When you are detecting PlayerAdded, you are executing plrJoined(). You are not providing the player argument, which the function seems to require to run.

I recommend using a function such as

game.Players.PlayerAdded:Connect(function(plr)
 --Put your code from the function here.
end)

and do the same for .PlayerRemoving

From my experience, you can’t track events using if/then statements.

Maybe instead, you could try

game.Players.PlayerAdded:Connect(plrJoined)
game.Players.PlayerRemoving:Connect(plrLeft)

@AIfre_d @eatabler0ck

I have tired both of these, but it just doesn’t work at all… Nothing is happening, not even the printing, it’s just blankness.

1 Like

You aren’t passing the Player argument which your two functions require.

Try using:

game:GetService(“Players”).PlayerAdded:Connect(function(Player)
plrJoined(Player)
end)

and


game:GetService(“Players”).PlayerRemoving:Connect(function(Player)
plrLeft(Player)
end)

1 Like

Keep the object which has to be cloned in ReplicatedStorage where client and server both can access it

Your firing it with 0 arguuments

This function you pasted have a plrleft argument, which is nil in this case

Also look here, game.Players.PlayerAdded is a function, you cannot do like this one you did below