I want the script below to weld the "shield" part to the player's right arm whenever the "G" key is pressed. However, I don't know how to refer to a player without using PlayerAdded, so what would I do in this case?
UIS = game:GetService("UserInputService")
isNear = game:GetService("ReplicatedStorage").Values.isNearShield
debounce = false
UIS.InputBegan:Connect(function(inputObj, gameProcessed)
if gameProcessed then
return
elseif inputObj.KeyCode == Enum.KeyCode.G and not debounce and isNear == true then
debounce = true
local shield = script.Parent:Clone()
shield.CanCollide = false
shield.Anchored = false
shield.Parent = player.Character
local rightArm = player.Character.RightUpperArm
local weld = Instance.new("Weld")
weld.Part0 = rightArm
weld.C0 = CFrame.new(0.5, 0, 0) * CFrame.fromEulerAnglesXYZ(0, math.pi/2, 0)
weld.Part1 = shield
weld.Parent = shield
end
wait(5)
debounce = false
end)

3 comments
for i,v do in pairs(game.Players:GetChildren()) do print(v.Name) end v would be the player
What is the mission?
A) This does not look like a server script. It looks like a local script. B) If it is a local script, there are many things wrong with your code.