Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why is this sword script giving a sword to everyone, not just the people in the group?

function onPlayerSpawned(player) if player:GetRankInGroup(4012232) <= 100 then game.Lighting.Sword:Clone().Parent = player.Backpack end end

game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function() onPlayerSpawned(player) end) end)

Basically, its trying to give a sword to people above the rank of Soldier, but for some reason everyone is given the sword.

2 comments

0

If the sword is given to everyone, then I would guess that the problem lies in the group itself. Everyone in the group has a rank higher than 100. You'll have to get the group leader to fix it.

0

Everyone except the soldiers perhaps. <= is less than or equal to. From the sounds of it, you want it to be >= which is greater than or equal to?

1 answer

You have a few doozies in this. If it's 100 and higher you want then use the script below.

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function()
        if plr:GetRankInGroup(4012232) >= 100 then
            local sworddupe = game.Lighting.Sword:Clone()
            sworddupe.Parent = plr.Backpack
        end
    end)
end)

1 comment

0

I have stared at this script for over 2 hours, and I feel completely stupid that I got the > wrong.

This discussion is preserved as it was. New answers, comments, and votes are closed.