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

Anchored character doesn't take damage?

I've been trying to make a fully anchored character take damage.

My touched script:

script.Parent.Touched:Connect(function(p)
	if p and script.Parent.CanDamage.Value == true and script.Parent.Parent.Parent.Name ~= p.Parent.Name and p.Parent:FindFirstChild("Humanoid") ~= nil  then
		script.Parent.CanDamage.Value = false

		local scc = script.TakeDamage:Clone()
		scc.Parent = p.Parent
		scc.Disabled = false
	end
end)

(Another script refreshes the value to true again after a certain amount of time)

The TakeDamage script:

repeat wait() until script.Parent.HumanoidRootPart.Anchored == false
wait(0.1)
script.Parent.Humanoid:TakeDamage(6)
script:Remove()

1 answer

✓ Accepted answer

If you want find the player with touching an part, You need to use like this

local Players = game:GetService("Players")

script.Parent.Touched:Connect(function(hit)
	if Players:GetPlayerFromCharacter(hit.Parent) then
	local Player = Players[hit.Parent.Name]
	--etc
	end
end)

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