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

[OPEN] Searching for player in Players returns nil?

Asked by 3 years ago
Edited 3 years ago

I'm trying to give players on a specific team a tool. I have this script

for c = 1, #sciPlrs do
        local sPlayer = sciPlrs[c]
        print(sPlayer)
        local sPlr = game.Players:FindFirstChild(sPlayer)
        print(sPlr)
                    game.Players:FindFirstChild(sPlayer.Name).PlayerGui:WaitForChild("SideStuff").Enabled = false   
        sPlayer.CameraMode = "LockFirstPerson"      
        print("Searching")
        --local pCloneBool = sPlr:FindFirstChild("PlayerScripts"):FindFirstChild("PlayerSettings"):FindFirstChild("PotionCloned")
        if --[[pCloneBool.Value == false and --]]  sPlayer:FindFirstChild("Health Potion") == nil then
            print("Object Cloned!")
            local pClone = PotionObject:Clone()
            pClone.Parent = game.Players:FindFirstChild(sPlayer.Name).Backpack
            --pCloneBool.Value = true
        end
        print("Done Searching")
        wait(1)
    end 

Which works fine except for the part where it tries to find the "sPlr" which is the player in the Players tab. When I print the sPlayer value it says the player name but with the sPlr it prints 'nil'. All the variables are fine except sPlr. Any way of finding the player in the Player Tab?

Please Help!

0
Is sPlr the local player? If so, why not just use Players.LocalPlayer? SuchASaltyLemon 35 — 3y
0
This is a server script so I cant use local player... strangejmaster43 139 — 3y

Answer this question