Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to kill a player from an object value?

Asked by 6 years ago

hi, i made a gun script that has a objectvalue that test if that value has a humanoid. if it does it removes some health. but it won't damage anything? please help!

local plr = game.Players.LocalPlayer
local char = plr.Character
local target = script.Parent.Target
local tracking = false
local canuse = true
local mouse = plr:GetMouse()

script.Parent.Equipped:Connect(function()
    tracking = true
end)
while wait() do
    if tracking == true then
        target.Value = mouse.Target
    end
end
script.Parent.Activated:Connect(function()
    if target.Value.Parent.Humanoid ~= nil then
        target.Value.Parent.Humanoid.Health = target.Value.Humanoid.Health-10
    end
end)
script.Parent.Unequipped:Connect(function()
    tracking = false
end)
0
How can an object be nil? hiimgoodpack 2009 — 6y
0
it tests if the object isn't nil (aka ~=) DevRolizzard 13 — 6y
0
Not apart of the problem, but you use :TakeDamage(damage) instead to make decreasing health simpler MadWorlds 84 — 6y

Answer this question