Im trying to destroy a model after all the parts in the shape’s activated value is true, but for some reason it does not work
its probably gonna be a dumb problem with an easy fix
here is the code:
local cutter = game.Workspace.cutter
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local HRP = player.Character:WaitForChild("HumanoidRootPart")
local Mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")
local shapeParts = game.Workspace.Shape:GetChildren()
local shape = game.Workspace.Shape
local isMouse_HELD = false
game:GetService("RunService").RenderStepped:Connect(function()
cutter.Position = Vector3.new(Mouse.Hit.X, Mouse.Hit.Y , Mouse.Hit.Z)
end)
Mouse.TargetFilter = cutter
UIS.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.MouseButton1 and Mouse.Target:IsA("Part") and Mouse.Target.Name == "cuttablePart" then
Mouse.Target.BrickColor = BrickColor.new("Sage green")
Mouse.Target.Activated.Value = true
for _, activatedParts in pairs(shapeParts ) do
if activatedParts.Activated == true then
shape:Destroy()
end
end
elseif Mouse.Target.Name == "uncuttablePart" then
Mouse.Target.Value.Value += 1
Mouse.Target.BrickColor = BrickColor.new("Really red")
if Mouse.Target.Value.Value >= 5 then
player.Character.Humanoid.Health = 0
end
end
end
end)
local cutter = game.Workspace.cutter
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local HRP = player.Character:WaitForChild("HumanoidRootPart")
local Mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")
local shapeParts = game.Workspace.Shape:GetChildren()
local shape = game.Workspace.Shape
local isMouse_HELD = false
game:GetService("RunService").RenderStepped:Connect(function()
cutter.Position = Vector3.new(Mouse.Hit.X, Mouse.Hit.Y , Mouse.Hit.Z)
end)
Mouse.TargetFilter = cutter
UIS.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.MouseButton1 and Mouse.Target:IsA("Part") and Mouse.Target.Name == "cuttablePart" then
Mouse.Target.BrickColor = BrickColor.new("Sage green")
Mouse.Target.Activated.Value = true
for _, activatedParts in pairs(shapeParts) do
if activatedParts.Activated.Value then
shape:Destroy()
end
end
elseif Mouse.Target.Name == "uncuttablePart" then
Mouse.Target.Value.Value += 1
Mouse.Target.BrickColor = BrickColor.new("Really red")
if Mouse.Target.Value.Value >= 5 then
player.Character.Humanoid.Health = 0
end
end
end
end)
This won’t work but everything looks fine, probably some issue with your references to external instances.