#help
41 messages · Page 1 of 1 (latest)
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
still trying to get a touched event from a table
what table
notice how LuckyBlock is a :GetDescendants()
local LuckyBlock = game.workspace.LuckyBlocks:GetDescendants()
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
thank you
tell me if it works
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 `
lemme try it rq
just use a for loop
** You are now Level 11! **
ok lemme learn that
oh its more simple
heres a rundown if you need it
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 `
u need to do block:destroy()
ohh