I have a server script inside this spike trap that I’m trying to only damage a monster and not the players. Yet I’m stumped on how to define player in a server script.
local part = script.Parent
part.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and hit.Parent ~= player.Character then
local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
humanoid1:TakeDamage(5)
wait()
end
end)
local part = script.Parent
part.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and hit.Parent ~= player.Character then
local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
humanoid1:TakeDamage(5)
task.wait()
end
end)
local part = script.Parent
part.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
humanoid1:TakeDamage(5)
task.wait()
end
end)
It doesnt make sense, on one hand you want to check for that player, but on the second hand, you dont want.
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) and game.Players:GetPlayerFromCharacter(hit.Parent) == nil then
hit.Parent.Humanoid:TakeDamage(5)
end
end)
local part = script.Parent
part.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and game.Players:FindFirstChild(hit.Parent) == nil then
local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
humanoid1:TakeDamage(5)
task.wait()
end
end)