I've got a server script that puts on a hat if a player clicks the hat, all of the script works perfectly except for the new part that I've added that checks what team the player is on before putting the hat on the player, It outputs no errors, but just does nothing.
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)
Could someone tell me why? Thanks!

7 comments
put quotes around Hunters on line 24
Did the game print "ClickRegistered"? If yes then try adding print function in the if statements to detect where the script stopped. If no then report engine bug :)
Didn't work
Does print "ClickRegistered", added some other ones and yeah it stops at line 24 where it checks if the player is on the team
is it because you are calling Playername? let's say its your username it would call CheeseBallGuy11.Team
Yeah playername is just the username
if player.Team == game.Teams["TEAM NAME"] then ... end || In your case, it would be game.Teams.Hunters