I have working simulator tool that when you click near a block it will get cut down. after few seconds it grows back just like in bee swarm simulator. So My question is how can I make it so that instead of one block getting cut down, all the blocks that are touching the "TouchPart" will be cut. Here Is The Script. Thanks by the way!
local player = game.Players.LocalPlayer
local character = player.Character
cutting = false
collected = false
local leaderstats = game.Players.LocalPlayer:WaitForChild("leaderstats")
local duration = 1 -- How long til you can mine again
local rate = 0.1 -- How big the Wheat gets cut down.
--In this case every 2 seconds, the spade can be used. 1 Wheat is earned, cuts the Wheat .1 studs down.
script.Parent.Activated:connect(function(duration)
if cutting == false then
cutting = true
wait(duration)
cutting = false
end
end)
script.Parent.HitPart.Touched:connect(function(part)
if cutting == true and collected == false then
if part.Name == "WheatBlock" and collected == false then
collected = true
game.ReplicatedStorage.Events.ToolsEvents.cuters.RemoveEV:FireServer(part)
wait(duration)
collected = false
game.ReplicatedStorage.Events.ToolsEvents.cuters.AddEV:FireServer(part)
wait()
end
end
end)
this is the 2nd script:
cutting = false
collected = false
local duration = 1 -- How long til you can mine again
local earnings = 1 -- How much Cash earned each mine
local rate = 0.1 -- How big the Wheat gets cut down.
game.ReplicatedStorage.Events.ToolsEvents.cuters.RemoveEV.OnServerEvent:Connect(function(player, part)
local leaderstats = player:WaitForChild("leaderstats")
if leaderstats.Wheat.Value >= leaderstats.Capacity.Value then return end
leaderstats.Wheat.Value = leaderstats.Wheat.Value + earnings
leaderstats.GlobalWheat.Value = leaderstats.GlobalWheat.Value + earnings
if part.Name == "WheatBlock" then
for i = 0,5 do
part.CFrame = CFrame.new(part.Position + Vector3.new(0, -rate, 0))
if not part:FindFirstChild("Cutted") then
local boolValue = Instance.new("BoolValue")
boolValue.Name = "Cutted"
boolValue.Parent = part
boolValue.Value = true
end
end
end
end)
game.ReplicatedStorage.Events.ToolsEvents.cuters.AddEV.OnServerEvent:Connect(function(player, part)
if part:FindFirstChild("Cutted") then
local value = part:WaitForChild("Cutted")
if value.Value == true then
wait(5)
for i = 0,5 do
part.CFrame = CFrame.new(part.Position + Vector3.new(0, rate, 0))
if value then
value:Destroy()
end
end
end
end
end)
