#NPC Cash drop and cash leaderboard + How do I respawn my npcs automatically?
59 messages · Page 1 of 1 (latest)
Make a script and name it "Regen" (put the script inside the NPC)
Then inside the script
Put this
z = script.Parent
backup = z:clone()
while true do
wait(5)
if z.Humanoid.Health == 0 then
z:Remove()
wait(6)
backup.Parent = game.Workspace
backup.Head:MakeJoints()
backup.Torso:MakeJoints()
end
if z == nil then
wait(9)
backup.Parent = game.Workspace
backup.Head:MakeJoints()
backup.Torso:MakeJoints()
end
end
u can change wait() time
Thank you man
I don’t know anything about scripting, there’s 3 waits, which one do I change
any of them
no bad
this will be much eaiser to use ```lua
z = script.Parent
backup = z:clone()
while true do
wait(5)
if z.Humanoid.Health == 0 then
z:Remove()
task.wait(2)
backup.Parent = game.Workspace
backup.Head:MakeJoints()
backup.Torso:MakeJoints()
elseif z == nil then
backup.Parent = game.Workspace
backup.Head:MakeJoints()
backup.Torso:MakeJoints()
end
end ```
use elseif
local function makeJoints(target)
target.Head:MakeJoints()
target.Torso:MakeJoints()
end
local function processCharacter(z, backup)
if z.Humanoid.Health == 0 then
z:Remove()
wait(6)
backup.Parent = game.Workspace
makeJoints(backup)
end
if z == nil then
wait(9)
backup.Parent = game.Workspace
makeJoints(backup)
end
end
local z = script.Parent
local backup = z:Clone()
while wait(5) do
processCharacter(z, backup)
end
** You are now Level 2! **
mine is more optimized
Ok thanks but which wait in that script do I change
Alr thank you
** You are now Level 3! **
Do you know how to make npcs drop cash upon dying, and a money leaderboard too? If not that’s ok
leaderboards use leaderboard service
let me write you a script that will show you the basics of the npc question.
5 hours later
oh
local npc = script.Parent -- Reference to the NPC character
local cashPart = game.ServerStorage.Coin:Clone() -- Assuming the Coin is stored in ServerStorage
npc.Humanoid.Died:Connect(function()
-- NPC has died, create a cash part and position it near the NPC
local cashClone = cashPart:Clone()
cashClone.Parent = game.Workspace -- Move the cash part to the Workspace
cashClone.CFrame = npc.HumanoidRootPart.CFrame + Vector3.new(0, 5, 0) -- Adjust the position as needed
cashClone.Anchored = false -- Allow it to fall
cashClone.CanCollide = true -- Allow interaction with it
cashClone.Touched:Connect(function(hit)
-- Optionally, you can add logic here to detect when a player touches the cash part and collect it.
if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
-- A player touched the cash; you can give the player currency or perform other actions.
cashClone:Remove() -- Remove the cash part once collected.
end
end)
end)
i had it saved but forgot to send it haha
it's a baseline, not code for your game.
i don't know the parents and hierarchy in your game. this is just to show you how a cash dropping system could work.
oh ok, do you have a script for it though? I will try to send whatever parent thing your looking for
i have a script but its ment for handling respawing and attacking the player
because we don't have access to your game
everything we've sent is baselines
you need to change stuff within the script
it’s all good, I’m using a new zombie ai with built in respawn script, it has the perfect features except for animations
And sadly I can’t animate a good zombir animation
I needa know how to animate 😭😭😭
go on youtube and search roblox blender animation tutorial
What I meant was like I know how to animate but I can’t make a good animation
** You are now Level 5! **
how much is it to hire an animator
for a good zombie run idle and walk animation how much would that cost
i could do it for like 5000 robux or ¥2400
