#Why doesnt the drop weapon system work?

91 messages · Page 1 of 1 (latest)

rare stirrup
#

is there an error?

#

or, what is the issue exactly?

sharp osprey
rare stirrup
#

what DOES it do

#

is there an error?

sharp osprey
#

what

#

i told u

rare stirrup
#

like an output error

sharp osprey
#

no

#

it just doesnt work

rare stirrup
#

send the place file if you may

sharp osprey
#

why

#

script is there

#

i told u why it doesnt work

#

now help me find out why it isnt working please

rare stirrup
#

so that i can narrow it down easier

#

looks alright on the surface

#

but there could be other factors

#

does the original tool get destroyed correctly?

sharp osprey
#

it works perfectly for npcs

#

just not players

rare stirrup
#

show me the code for the npcs? what's the difference?

#

as in npcs death code for the same feature

sharp osprey
#

one second

#

this the code for when the nmpc dies

#

dont mind the hp part

#

thats for healing the player when they kill an npc

rare stirrup
#

okay

#

could you add a print here and see what it says?

#

in original code

sharp osprey
#

okay

rare stirrup
#

just after parenting the replica

sharp osprey
#

like i said the npc script works perfectly

#

its just when the player dies with a tool it doesnt create a replica

rare stirrup
#

print what the parent of the replica is

#

and i mean in the original code, not npc code

sharp osprey
#

what for players?

rare stirrup
#

yeah

sharp osprey
#

my bad

rare stirrup
#

no prob bob

sharp osprey
#

it prints out

#

so it does set the parent to workspace

#

but when i go back to where i died theres no replica

rare stirrup
#

check the explorer - it ought to show up there when you die

#

maybe just a positioning issue

#

OH

#

sorry, just worked it out

#

you set the Y position to 5

sharp osprey
#

oo okay

rare stirrup
#

when you set the cframe

#

it should be the player's position +5, presumably

sharp osprey
#

ohh

#

huh

#

stil doesnt work

#
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local humanoid = character:WaitForChild("Humanoid")
        local rootPart = character:WaitForChild("HumanoidRootPart")

        if not rootPart then return end

        humanoid.Died:Connect(function()
            local posX, posY, posZ = rootPart.Position.X, rootPart.Position.Y, rootPart.Position.Z

            local tool = character:FindFirstChildOfClass("Tool") or player.Backpack:FindFirstChildOfClass("Tool")
            
            if tool then
                tool:Destroy()

                local replica = game.ReplicatedStorage.PlaceholderReplica:Clone()

                for _, part in ipairs(replica:GetDescendants()) do
                    if part:IsA("BasePart") or part:IsA("MeshPart") then
                        part.CanCollide = true
                        part.Massless = false
                    end
                end

                replica:SetPrimaryPartCFrame(CFrame.new(posX, posY + 5, posZ))
                replica.Parent = workspace
                print("works")
            end 
        end)
    end)
end)
#

also the replica doesnt appear in workspace in the explorer

#

@rare stirrup

rare stirrup
#

hi was getting food

#

hmm

#

if it's not too big, sending it would help me debug it :) but no worries if you dont want to

#

weird that it doesnt appear in the explorer if it prints the parent, assuming you did test that

sharp osprey
#

yep

bleak patrolBOT
#

studio** You are now Level 6! **studio

sharp osprey
#

also i tried printing out the posx y and z and i got this

#

so it is ercording the positions

#

but not cloning for some reason

rare stirrup
#

OH

#

yeah

#

its tracking the position of the root part when it's spawned

#

not when the character dies

sharp osprey
#

huh

#

but it records it after the humanoid dies

rare stirrup
#

yeah sry im dumb

#

eating rn can look at it more after

sharp osprey
#

yep

rare stirrup
#

or expected

sharp osprey
#

well anything around 0-5

#

i removed teh +5

sharp osprey
rare stirrup
#

hi

sharp osprey
#

hello

rare stirrup
#

honestly im not sure what else i can help with without the place file, it looks as if it ought to be working

sharp osprey
#

oh alright

#

well i’m off to bed anyway

rare stirrup
#

alrighty

#

sorry i couldnt help more