So I'm having trouble making this lucky block script un-equip once you use it. So what happens is once you use the lucky block, it deletes the current gears, gives a random, and automatically equips it. The problem is, you have to re-equip the gear, and this is a bit troublesome to the new players as they don't know what to do...
TL;DR Can someone fix it to where it will un-equip then re-equip once "activated"
local Tool = script.Parent
local gears = {173755801, 169669671, 220288991, 170897263, 98253592, 12547976, 45201977, 78730532}
function onActivated()
-- play sound
magicSound = Tool.Handle:FindFirstChild("MagicSound")
if magicSound == nil then return end
magicSound:Play()
-- GOOD RANDOMIZATION CODE!!
numLoops = math.random(0,math.floor(1000*time()))
numLoops = numLoops - (math.floor(numLoops / 10000)*10000)
for i = 1,numLoops do
whichNum = math.random(1,#gears)
end
-- END OF GOOD RANDOMIZATION CODE!
print("Picked: ")
print(whichNum)
local root = game:GetService("InsertService"):LoadAsset(gears[whichNum])
local instances = root:GetChildren()
if #instances == 0 then
root:Remove()
return
end
root = root:GetChildren()
if #root == 1 then
root = root[1]
else return end
print(root)
root.Parent = Tool.Parent
Tool:remove()
end
function onEquipped()
magicSound = Tool.Handle:FindFirstChild("MagicSound")
if magicSound == nil then
magicSound = Instance.new("Sound")
magicSound.Parent = Tool.Handle
magicSound.Volume = 1
magicSound.SoundId = "http://www.roblox.com/asset/?id=144007386"
magicSound.Name = "MagicSound"
end
end
Tool.Activated:connect(onActivated)
Tool.Equipped:connect(onEquipped)

1 comment
doesn't help :/