So i'm trying to detect when a part gets touched, and if hit has met a certain qouta, inflict damage. heres the script.
LOCAL SCRIPT
script.Parent.Main.Touched:connect(function(hit)
if hit.Parent.Name ~= player.Name then
if hit.Parent.Humanoid then
if CanDamage.Value == true then
script.Parent.DamageEvent:FireServer(hit.Parent.Name)
CanDamage.Value = false
end
end
end
end)
SERVER SCRIPT
DamageEvent.OnServerEvent:connect(function(playerhit)
print(playerhit)
workspace:FindFirstChild(playerhit).Humanoid:TakeDamage(30)
end)
so when i press play and hit something, (the output should say four, since im hitting a dummy named four), the output prints out the local players name. and saying its a nil value- even though ive checked over everything and it should be working.
Envoked
02:55:47.252 - Players.Envoked.Backpack.Test Sword.Yeah:36: attempt to index a nil value
02:55:47.252 - Stack Begin
02:55:47.253 - Script 'Players.Envoked.Backpack.Test Sword.Yeah', Line 36
02:55:47.253 - Stack End

1 comment
LocalScripts can’t run under the Workspace...