#NPC Cash drop and cash leaderboard + How do I respawn my npcs automatically?

59 messages · Page 1 of 1 (latest)

hearty snow
#

👋

#

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

opal sapphire
#

Thank you man

#

I don’t know anything about scripting, there’s 3 waits, which one do I change

ebon parrot
#

use elseif

hearty snow
#
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
acoustic sandBOT
#

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

hearty snow
#

mine is more optimized

opal sapphire
#

Ok thanks but which wait in that script do I change

hearty snow
#

any of them

#

you can set the time on each one to fit your purposes

opal sapphire
#

Alr thank you

acoustic sandBOT
#

studio** You are now Level 3! **studio

opal sapphire
#

Do you know how to make npcs drop cash upon dying, and a money leaderboard too? If not that’s ok

hearty snow
#

let me write you a script that will show you the basics of the npc question.

hearty snow
#

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

opal sapphire
#

Thank you bro 🙏🙏🙏

#

do I put this in leaderboard service or somethin

hearty snow
#

i don't know the parents and hierarchy in your game. this is just to show you how a cash dropping system could work.

opal sapphire
#

oh ok, do you have a script for it though? I will try to send whatever parent thing your looking for

opal sapphire
#

I just tested all 3 of the respawn scripts u guys gave me

#

None of em worked

opal sapphire
#

is there anything i gotta do

#

cause they aint work

ebon parrot
hearty snow
#

everything we've sent is baselines

#

you need to change stuff within the script

opal sapphire
#

And sadly I can’t animate a good zombir animation

#

I needa know how to animate 😭😭😭

hearty snow
opal sapphire
acoustic sandBOT
#

studio** You are now Level 5! **studio

hearty snow
#

practice

#

or hire someone

opal sapphire
#

how much is it to hire an animator

opal sapphire
hearty snow
opal sapphire
#

50 dollars worth of robux 😭😭😭

#

I think I’ll just try to animate it myself

hearty snow
opal sapphire
hearty snow
#

who the fuck buys robux

#

that doesnt even make sense