I want to give a person who has a specific role "Hider" an item but it is not working ; can someone please verify that my code is correct. Additionally, I do have a cheese block + configuration in my server storage. I have pasted my code and this is only a little part of the full code which is about how players step on the GUIPAD then get teleported to a map and then yeah. Can someone verify my code is correct please because it is not working.
if AssignRoleEvent then
currentPlayers = Players:GetPlayers()
if #currentPlayers > 0 then
print("[MapsHandler] Assigning roles to", #currentPlayers, "players.")
local hiderIndex = math.random(#currentPlayers)
local hiderPlayer = currentPlayers[hiderIndex]
print("[MapsHandler] Selected Hider:", hiderPlayer.Name)
local weaponsFolder = ServerStorage:FindFirstChild("Weapons")
local cheeseBlockTemplate = nil
if weaponsFolder then
cheeseBlockTemplate = weaponsFolder:FindFirstChild("CheeseBlock")
end
for _, player in currentPlayers do
local role
if player == hiderPlayer then
role = "Hider"
print("[MapsHandler] Assigning Hider role to", player.Name)
if cheeseBlockTemplate then
local playerBackpack = player:FindFirstChild("Backpack")
local cheeseClone = cheeseBlockTemplate:Clone()
cheeseClone.Parent = playerBackpack
end
** You are now Level 2! **