Wednesdays 10:00AM - 12:00PM Pacific
Join the Zoom
Download Roblox
Jump to recap
Put a hole in a part
Damage block
Damage block code
local damagePart = script.Parent
local function onPartTouch(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.Health = 0
end
end
damagePart.Touched:Connect(onPartTouch)
Coin Collection
Coin Collection Code
local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
local coinsFolder = Workspace.Coins
local coins = coinsFolder:GetChildren()
local COOLDOWN = 10
local function onCoinTouched(otherPart, coin)
if coin:GetAttribute("Enabled") then
local character = otherPart.Parent
local player = Players:GetPlayerFromCharacter(character)
if player then
coin.Transparency = 1
coin:GetAttribute("Enabled", false)
print("Player collected a coin")
task.wait(COOLDOWN)
coin.Transparency = 0
coin:GetAttribute("Enabled", true)
end
end
end
for _, coin in coins do
coin:SetAttribute("Enabled", true)
coin.Touched:Connect(function(otherPart)
onCoinTouched(otherPart, coin)
end)
end