This is the script:
wait()
function onTouched(part)
local h = part.Parent:FindFirstChild("Humanoid")
local character = h.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player then
print("Player is " .. player.Name)
else
print("Player doesn't exist!")
local dmg = player.PlayerStats.Melee.Value
if h~=nil then
local anim = h:LoadAnimation(script.anim)
h:TakeDamage(dmg)
anim:Play()
end
end
wait(1)
end
script.Parent.Touched:connect(onTouched)
So i need to get the player from the character so i can get the player's melee stat and use it as the damage value, but this script results in an error, this is what my output displayed:
Workspace.iiiAmericanLight.RightHand.Dmg.Script:20: attempt to index local 'player' (a nil value)

1 comment
Why are you using player when you know it does not exist???