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

the tools dose with work with player work in work space how do i fix?

Asked by 5 years ago
Edited 5 years ago

the a player has it and touches something it wont work at all but when he/she drops it and trys to pick it up it works idk whats wrong

script.Parent.Activated:Connect(function()
script.Parent.Handle.Script.Disabled = false
end)

the script

function onTouch(part) 
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then   -- if a humanoid exists, then
        humanoid.Health = 0 -- damage the humanoid
    end 
end

script.Parent.Touched:connect(onTouch)

0
What would you like to happen?? Player A holds the tool and if ANOTHER player touches it they get the damage? GoodCallMrOlsen 70 — 5y
0
yeah helleric -3 — 5y
0
what if u just make it undroppable TheluaBanana 946 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

You can then use a remote event to fire to the server the hit.Parent and on the server side set it's Humanoid Health to 0

local tool = script.Parent
local player = game.Players.LocalPlayer

local function onTouch(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid")
    if hum then 
        --Fire a Remote Event to kill hit.Parent [i.e. onKillPlayerEvent:FireServer(hit.Parent)]
    end
end


tool.Blade.Touched:Connect(function(hit)
        onTouch(hit)
end)
0
it works when the player drops it and trys to pick it up it kills the player helleric -3 — 5y
0
never mind i fixed it ty helleric -3 — 5y
Ad

Answer this question