#help

41 messages · Page 1 of 1 (latest)

fringe laurel
#

youre trying to get a .Touched event from a table

balmy cave
#

just make it a normal function

#

like literally

#
 local LuckyBlock = game.workspace.LuckyBlocks:GetDescendants()
local RS = game:GetService("ReplicatedStorage")

local rng = math.random(1, 3)

local Zombie = RS.Zombie
local Speedy = RS.Speedy
local Tough = RS.Tough

LuckyBlock.Touched:Connect(function(hit)
  if hit.Parent:FindFirstChild("Humanoid")
    print("Something Touched Lucky Block")
        if rng == 1 then
            Zombie:Clone()
            Zombie:Clone().Parent = workspace
        elseif rng == 2 then
            Speedy:Clone()
            Speedy:Clone().Parent = workspace
        else 
            Tough:Clone()
            Tough:Clone().Parent = workspace
    end
end
end)
#

i also assumed you wanted only players to be able to touch it right

fringe laurel
balmy cave
#

what table

fringe laurel
#

notice how LuckyBlock is a :GetDescendants()

#

local LuckyBlock = game.workspace.LuckyBlocks:GetDescendants()

balmy cave
#

oh

#

one sec then

flat oak
#

whats a event from a table

#

im kinda new in coding

balmy cave
#
 local LuckyBlock = game.workspace.LuckyBlocks:GetDescendants()
local RS = game:GetService("ReplicatedStorage")

local rng = math.random(1, 3)

local Zombie = RS.Zombie
local Speedy = RS.Speedy
local Tough = RS.Tough

for _, block in pairs(LuckyBlock) do
if block:IsA("BasePart") then
block.Touched:Connect(function(hit)
  if hit.Parent:FindFirstChild("Humanoid")
    print("Something Touched Lucky Block")
        if rng == 1 then
            Zombie:Clone()
            Zombie:Clone().Parent = workspace
        elseif rng == 2 then
            Speedy:Clone()
            Speedy:Clone().Parent = workspace
        else 
            Tough:Clone()
            Tough:Clone().Parent = workspace
        end
    end
  end)
end
end
#

something like that, no?

#

i wouldnt go straight to setting a variable straight to descendants but if thats what your game needs then

#
 local LuckyBlock = game.workspace.LuckyBlocks
local RS = game:GetService("ReplicatedStorage")

local rng = math.random(1, 3)

local Zombie = RS.Zombie
local Speedy = RS.Speedy
local Tough = RS.Tough

for _, block in pairs(LuckyBlock:GetDescendants()) do
if block:IsA("BasePart") then
block.Touched:Connect(function(hit)
  if hit.Parent:FindFirstChild("Humanoid")
    print("Something Touched Lucky Block")
        if rng == 1 then
            Zombie:Clone()
            Zombie:Clone().Parent = workspace
        elseif rng == 2 then
            Speedy:Clone()
            Speedy:Clone().Parent = workspace
        else 
            Tough:Clone()
            Tough:Clone().Parent = workspace
        end
    end
  end)
end
end
``` or just use this
flat oak
#

thank you

balmy cave
#

tell me if it works

flat oak
#

btw can you explain why didnt this work?
` local i = 1

if i < 100 then
repeat
i = i + 1
task.wait()
until
i == 100
end `

flat oak
umbral pantherBOT
#

studio** You are now Level 11! **studio

flat oak
balmy cave
#
for i=1,100,1 do
    task.wait()
end
#

then just put ur code after the loop

flat oak
#

oh its more simple

balmy cave
#

heres a rundown if you need it

flat oak
# balmy cave tell me if it works

it works perfectly fine but when i tried to add LuckyBlocks:Destroy to destroy the lucky block, the lucky blocks doesnt dissapear

heres the code
` local LuckyBlock = game.workspace.LuckyBlocks:GetDescendants()
local RS = game:GetService("ReplicatedStorage")

local rng = math.random(1, 3)

local Zombie = RS.Zombie
local Speedy = RS.Speedy
local Tough = RS.Tough

for _, block in pairs(LuckyBlock) do
if block:IsA("BasePart") then
block.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
print("Something Touched Lucky Block")
if rng == 1 then
Zombie:Clone()
Zombie:Clone().Parent = workspace
LuckyBlock:Destroy()
elseif rng == 2 then
Speedy:Clone()
Speedy:Clone().Parent = workspace
LuckyBlock:Destroy()
else
Tough:Clone()
Tough:Clone().Parent = workspace
LuckyBlock:Destroy()
end
end
end)
end
end `

flat oak
#

ohh

balmy cave
#

also

#

only use else for boolvalues

#

do elseif rng == 3 then

#

luckyblock is the entire folder

#

block is just the descendant

#

got it?

flat oak
#

ok

#

yeah

#

i thought luckyblocks was part inside of it