#why doesnt my npc die normally
1 messages · Page 1 of 1 (latest)
make sure the NPC is unanchored and BreakJointsOnDeath is true inside the Humanoid
how do I unanchor him? it doesnt show anything like that when I look at the properties
just click the NPC and uncheck this button at the top
holy you're genious
did it fix everything?
yeah it did bro thanks
nice, np
also if u didnt mind me asking, how would I go about making it respawn
** You are now Level 1! **
like a bloxfruits npc
you would have to make a script probably that clones the NPC
first drag your NPC into ReplicatedStorage
you can keep it named "Shark03D" if you want you just have to make sure it lines up in the script
i'll write a simple script that should work
so basically I have to clone it to the workspace whenever one dies?
I mean sure if u want, just as long as I can learn from it
yeah thanks
how much coding knowledge do you have already?
hmmm
I literally started using studio like 2 weeks ago and ive been learning scripting from yt tutoiral serires lol
I can understand what a lot of stuff does but if I dont know how to use it myself ill watch tutorials to learn it
alr ill try my best to explain everything
thanks
here you go
Put this in a new script inside ServerScriptService:
local NPC = game.ReplicatedStorage:WaitForChild("Shark03D")
-- Get the NPC above, and wait for it if it hasnt loaded in yet.
-- Stores it into the variable named "NPC" so we can easily reference it.
function createNPC() -- create a new function to spawn the NPC
local clone = NPC:Clone()
clone.Parent = workspace
-- The code above creates a clone of the NPC and puts it inside workspace
local humanoid = clone:WaitForChild("Humanoid") -- wait for the clone's humanoid to load in and store it inside a variable
humanoid.Died:Connect(function()
task.wait(1)
createNPC()
clone:Destroy()
end)
-- Above connects a new function that will run once the clone has died
-- it will run the function "createNPC" again 1 second after its death
-- then it will destroy the old clone that already died
end
createNPC() -- calls the function to create the very first NPC
and here is the same code without the comments
local NPC = game.ReplicatedStorage:WaitForChild("Shark03D")
function createNPC()
local clone = NPC:Clone()
clone.Parent = workspace
local humanoid = clone:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
task.wait(1)
createNPC()
clone:Destroy()
end)
end
createNPC()
yoo bro I cant thank you enough
its np, let me know if you need any more help with it
when u said 'function createNPC()' why isnt there a local infront? im just curious because a lot of the time most variables or functions start with local
You can make that function local if you wanted, normally i would too but i left it out to keep it simple. Most variables and functions you would put local behind, except for functions that aren't inside any other functions. Those don't have to have local in front
like this for example, test1 works with or without a local in front. but test2 needs a local in front because its inside test1. That means test2 can only be called within test1
function test1()
local function test2()
print('something')
end
test2()
end
test1()
so scope has something to do with it?
yeah excluding local means it is a global function that can be called anywhere in the script basically
bro its crazy how helpful you are lol
** You are now Level 2! **
I understand everything youve said
ty wow, im glad i was able to help
im not used to teaching people but i have a lot of experience programming
thats fair
Im confused on how you wrote the scripts inside a blue box, like is it a discord feature?