New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Why is the bot detecting itself?

Asked by 8 days ago

Im trying to fire an event when the bot dies.With the name of the player in it so the script knows who killed the bot.Here is the script: P.S It is very important for me because otherwise the quest cant work,pls help. Im always getting the error "Monkey is not a valid member of Players" but why is it detecting itself,btw monkey is the bot.

Local:

local Humanoid = script.Parent.Humanoid
local delayy = false
local remote = game.ReplicatedStorage.Check2
script.Parent.HumanoidRootPart.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid")then
        local plr = game.Players[hit.Parent.Name] 
        elseif hit:FindFirstChild("PlayerName")then
        local plr = game.Players[hit.PlayerName.Value]
script.Parent:WaitForChild("Humanoid").Died:Connect(function()

    if delayy == false then
remote:FireAllClients(plr)
delayy = true
print("died")
wait(1)
delayy = false
end
end)
end
end)

1 answer

Log in to vote
1
Answered by 8 days ago
Edited 8 days ago

local Humanoid = script.Parent.Humanoid local delayy = false local remote = game.ReplicatedStorage.Check2 script.Parent.HumanoidRootPart.Touched:Connect(function(hit) hum = hit.Parent:FindFirstChild("Humanoid") local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then Humanoid.Died:Connect(function() if delayy == false then remote:FireClient(plr) delayy = true print("died") wait(1) delayy = false end end) end end)
0
Bout to eat with family. If that doesn’t work I’ll look over it again later sorry. SethHeinzman 268 — 8d
0
Bout to eat with family. If that doesn’t work I’ll look over it again later sorry. SethHeinzman 268 — 8d
0
Oh when the bot dies sorry! I’ll change it real quick SethHeinzman 268 — 8d
Ad

Answer this question