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

Part.Touched event doesnt detect ragdoll?

Asked by 4 years ago

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)
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? User#27525 1 — 4y
0
im a beginner and i have no idea how to TFlanigan 86 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

Is your Script a local script?

0
oh yeah i forgot instances created with local scripts arent detected by other scripts TFlanigan 86 — 4y
0
however im going to have a hard time changing the script to make it work as a normal script TFlanigan 86 — 4y
0
idk if its possible tho :/ TFlanigan 86 — 4y
0
ok did it just gotta fix some things TFlanigan 86 — 4y
View all comments (3 more)
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 ffancyaxax12 181 — 4y
0
This should really be a comment instead of an answer as you made the answer a question. ProbablyRiley 0 — 4y
0
you should know buddy ProbablyRiley 0 — 4y
Ad
Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
4 years ago

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)
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 TFlanigan 86 — 4y
0
this fix still doesnt work :/ TFlanigan 86 — 4y
0
hello? TFlanigan 86 — 4y

Answer this question