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

Part.Touched event doesnt detect ragdoll?

so im making a game with a tombstone which is supposed to write something on the label when a player hits it. The problem is it only detects normal people, and it doesnt detect dead ragdolls. I'm not getting any errors, but here is what i made so far to make it work (it still doesnt tho)

local part = script.Parent
local text = part.Parent.Part.SurfaceGui.BuriedNickname
part.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		local plr = game.Players:GetPlayerFromCharacter(humanoid.Parent)
		text.Text = humanoid.Parent.Name .. "- died from some disease ~ lived for ".. plr.AccountAge .. " days."
	end
end)

2 comments

0

I think the problem is that when the body parts of the character are deleted, the touched event don't fire anymore. Since the problem is probably related with the ragdoll script, why don't you make your own?

0

im a beginner and i have no idea how to

2 answers

✓ Accepted answer

Is your Script a local script?

7 comments

0

oh yeah i forgot instances created with local scripts arent detected by other scripts

0

however im going to have a hard time changing the script to make it work as a normal script

0

idk if its possible tho :/

0

ok did it just gotta fix some things

0

oh im sorry was not online, yes the only way to change a local part is with local scripts. But you have to fire those with a Remote Event or Remote Function

0

This should really be a comment instead of an answer as you made the answer a question.

0

you should know buddy

You can check wether it's dead or not by checking if its Health is equal to zero, by doing humanoid.Health ~= 0

local part = script.Parent
local text = part.Parent.Part.SurfaceGui.BuriedNickname
part.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
	if humanoid.Health ~= 0 then
	        local plr = game.Players:GetPlayerFromCharacter(humanoid.Parent)
	        text.Text = humanoid.Parent.Name .. "- died from some disease ~ lived for ".. plr.AccountAge .. " days."
	    end
	end
end)

3 comments

0

oh yea i forgot to say, the ragoll script im using makes a new model and deletes almost everything from the old one. Let me screenshot the workspace: http://prntscr.com/qxjk7f

0

this fix still doesnt work :/

0

hello?

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