Hello, I have three identical dummies with all the same parts and each has this seperate script which is supposed to make a random number called chance and if the chance is equal to a certain number then drop the item but when printing it only creates the chance variable once and prints it once. Thanks for any help.
local dummy = script.Parent
dummy.Humanoid.HealthChanged:Connect(function()
if dummy.Humanoid.Health <= 0 then
local chance = math.random(1,10)
print(chance) -- Prints chance variable only once even when another dummy is destroyed
if chance == 5 then-- 100% chance
local gd = game.ReplicatedStorage.GoldenBall:Clone()
gd.Parent = workspace
gd.Position = dummy.HumanoidRootPart.Position
dummy:Destroy()
elseif chance <= 5 then
local ammo = game.ReplicatedStorage.Dodgeball:Clone()
ammo.Parent = workspace
ammo.Position = dummy.HumanoidRootPart.Position
dummy:Destroy()
else
dummy:Destroy()
end
end
end)
robloxapp-20240525-1727582.wmv (2.5 MB)
The output in this example printed only 7 once