How do i acces variables in this script?

The question in the title, please help me out. I wanna access to the player who touched the part and give them the Combat Shotgun. But in this script, the output says "Hit is not a valid member of game.Players :frowning:

local part = script.Parent
local spawns = workspace:WaitForChild("Map"):WaitForChild("Spawns")
local repStor = game:GetService("ReplicatedStorage")
local weapons = repStor:WaitForChild("Weapons")

part.Touched:Connect(function(hit)
	local find = spawns:GetChildren()
	local spawnChoose = find[math.random(1,#find)]
	local Char = hit.Parent
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if not Char then return end
	Char.HumanoidRootPart.Position = spawnChoose.Position
	weapons:WaitForChild("Combat Shotgun").Parent = game.Players.plr.Backpack
end)

Change

weapons:WaitForChild("Combat Shotgun").Parent = game.Players.plr.Backpack

To

weapons:WaitForChild("Combat Shotgun").Parent = plr.Backpack

You already get the player from GetPlayerFromCharacter. Also, change

if not Char then return end

To

if not Char or not plr then return end

To account if a non player touched the part so it wont error

Grammarly’s algorithms flag potential issues in the text and make context-specific suggestions to help with grammar, spelling and usage, wordiness, style, punctuation, and even plagiarism. https://grammarly.com