Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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.

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. zyrun 168 — 6y
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? Char187 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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)
0
I have stared at this script for over 2 hours, and I feel completely stupid that I got the > wrong. Regenerized 0 — 6y
Ad

Answer this question