#Giving an item to a player with a specific role

1 messages · Page 1 of 1 (latest)

elfin frost
#

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
earnest glacier
#

you're missing

#

ends

elfin frost
#

nevermind, i dont

dusty zephyrBOT
#

studio** You are now Level 2! **studio

elfin frost
elfin frost
#

ok I got it working to have a cheese block when i am hider but now, once it is in my hand, i want to be able to drag it , rotate it and place it just like in roblox studio (not scale it though) and to click to place it somewhere in my map so how would i do that