This code is for an item pickup system, and I only want players on a particular team to be able to pick it up. However, I get an error when the code runs.
player = game.Players.LocalPlayer
boostPack = script.Parent
plunger = script.Parent.Parent.Plunger
needle = script.Parent.Parent.Needle
serum = script.Parent.Parent.Serum
local function onPartTouch(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
if player.Team == "Doctor" then
local boosts = humanoid.Parent.Boosts
boosts.Value = boosts.Value + 1
boostPack:Destroy()
plunger:Destroy()
needle:Destroy()
serum:Destroy()
end
end
end
boostPack.Touched:Connect(onPartTouch)

1 comment
Is this a server or client script? Players.LocalPlayer is nil on the server.