Very simple question that I've completely lost myself to, got a server script that I use to allow a player to pick up an accessory, all of the script works except for the part that checks the players team.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("Headlamp")

local ClickDetector = script.parent:FindFirstChild("ClickDetector")
game.Players.PlayerAdded:Connect(function(Player)
	print(Player.Name)
end)

local Teams = game:GetService("Teams")
local Hunters = Teams:FindFirstChild("Hunters")

ClickDetector.MouseClick:Connect(function(Player) 
	
	print('ClickRegistered')
	
	local Headlamp = script.Parent
	local Playername = Player.Name
	print(Playername)
	local Playeruser = game.Workspace:WaitForChild(Playername)
	local Humanoid = Playeruser:WaitForChild("Humanoid")
	
	if Playeruser:FindFirstChild("Headlamp") == nil then
		
		if Playername.Team == Hunters then
		
		Humanoid:AddAccessory(Headlamp)
		remoteEvent:FireClient(Player)
	end
	end


end)


I've tried but nothing happens, could someone tell me why?

2 comments

0

Did it report any error?

0

No errors, just nothing happens at all