Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

3 comments

0

What would you like to happen?? Player A holds the tool and if ANOTHER player touches it they get the damage?

0

yeah

0

what if u just make it undroppable

1 answer

✓ Accepted answer

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)

2 comments

0

it works when the player drops it and trys to pick it up it kills the player

0

never mind i fixed it ty

This discussion is preserved as it was. New answers, comments, and votes are closed.