#No clue whats wrong.

92 messages · Page 1 of 1 (latest)

weak storm
#

if not humanoid then return end

earnest grove
#

ill try it

weak storm
#

wait wtf I say

#

no

earnest grove
#

ok

weak storm
#

use FindFirstChild from character

left badger
#

in what context? like a part's .Touched event?

weak storm
#

it return if child exist or no

earnest grove
#

No its just for a monster ai

dusty tendon
#

if Character:FindFirstChild("Humanoid") and Character.Humanoid.Health > 0 then

earnest grove
#

I want it to check if the players health is above 0

copper harborBOT
#

studio** You are now Level 1! **studio

earnest grove
left badger
#

any pleyear in the game? or does it have a target or something it's passing through

earnest grove
#

then checks if there health is above 0

#

should be other way around so ima do that

left badger
#

closest player or closest character

#

that logic checks out, what you're saying

dusty tendon
#
local Humanoid = Player.Character:FindFirstChild("Humanoid")
if Humanoid and Humanoid.Health > 0 then
  print("Player's Health is "..Health)
end
earnest grove
#

no clue why but It did

#

Thx

left badger
#

did you have it written exactly like xcosanxc2 did it?

earnest grove
#

He now doesnt bug out after killing the player

left badger
#

doubt

#

or else it wouldn't have errored

earnest grove
#

I guess if character.Humanoid then doesnt work

weak storm
#

yes

#

wouldnt

#

work

left badger
#

Character.Humanoid works fine if you know the humanoid exists

weak storm
#

but character:Find do

left badger
#

Character:FindFirstChild("Humanoid") returns nil if it doesnt have a humanoid

earnest grove
#

I mean its working now and Im not complaining

earnest grove
left badger
#

so with what xcosanxc2 wrote, it checks to see if a humanoid exists before actually referencing it and the health property attached to it

earnest grove
#

I can send the snipit

#

wait how do I send the script maped on discord

#

like whats the cmd

left badger
earnest grove
#

thx

#
local function findClosestPlayerNearby()
    local players = game:GetService("Players"):GetPlayers()
    local closestPlayer = nil
    local closestDistance = math.huge

    for _, player in pairs(players) do
        local character = player.Character
        if character then
            if character:FindFirstChild("Humanoid") then
                local Health = character.Humanoid.Health
                if Health > 0 then
                    local characterPosition = character.PrimaryPart.Position
                    local distance = (characterPosition - Root.Position).Magnitude

                    if distance <= detectionRadius and distance < closestDistance then
                        closestDistance = distance
                        closestPlayer = player
                    end
                end    
            else
                closestPlayer = nil
            end
        else
            closestPlayer = nil
        end
    end

    return closestPlayer
end
weak storm
#

just do this

#
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
local rootpart = character.HumanoidRootPart

player.CharacterAdded:Connect(function(newC)
    character = newC
    humanoid = newC:WaitForChild('Humanoid')
    rootpart = newC:WaitForChild('HumanoidRootPart')
end)
earnest grove
#

But idk why

#

lol

weak storm
#

reset character

#

then say that again

left badger
weak storm
left badger
#

you wrote a localscript

weak storm
#

sad

earnest grove
#

rip

#

wait what

#

whats this from

#

is this from the client?

left badger
#

post a larger screenshot

earnest grove
#

cuz it doesnt appear when im veiwing server side to watch the monster move around after I died and death screen shows up

left badger
#

like one that captures more of the screen

earnest grove
#

ok

#

W death screen

left badger
#

clientside

#

is my best guess

earnest grove
#

Ok so I dont need to worry about it?

left badger
earnest grove
#

yeah

left badger
#

my studio shows it differently

earnest grove
#

well its a warn

#

so I never use warn so I think its rbx scripts

left badger
#

do you have CharacterAutoLoads set to false?

dusty tendon
earnest grove
earnest grove
#

its set to 1

earnest grove
#

So It can handle the loading of the game better

#

Cuz after u die the spectate script still detects the character

#

so I could just make a dead r not value

left badger
#

might be worth looking up the warn message

#

just to educate yourself on it

earnest grove
#

Wait no

#

character autoloads is on true

#

Im gunan put it on false and see if it bothers me

copper harborBOT
#

studio** You are now Level 2! **studio

earnest grove
#

Just anoying and I didnt wana flood the output

#

Ik what happened