So I have been working on a rpg and I couldn't figure out how to make a npc when killed have a chance to give you a item like a sword.
I am using this code idk why it doesn't work I'm not getting any errors and I don't see any problems
local humanoid = script.Parent:FindFirstChild("Humanoid") local rp = game:GetService("ReplicatedStorage") local drop = rp.drop:FindFirstChild("Livingwood_Dagger") local hr = script.Parent:FindFirstChild("HumanoidRootPart") humanoid.Died:Connect(function() local dropChance = math.random(1, 2) if dropChance == 1 then local clone = drop:Clone() clone.Parent = workspace local Handle = clone:FindFirstChild("Handle") if Handle then Handle.CFrame = hr.CFrame end end end)
Closed as Not Constructive by MarkedTomato and JesseSong
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?