I made a script for a hammer tool which's purpose is whenever I hit a specific part (called Wall1) it increases in specifically vertical/Y part size by using
Wall1.size = Wall1.size + Vector3.new(0,1,0)
But now I have 2 issues.
How do I solve both of these?
Hammer Tool Script
local Tool = script.Parent local HammerHead = Tool.HammerHead local Wall1 = game.Workspace.Wall1 local function onTouch(partTouched) local canBuild = partTouched.Parent:FindFirstChild("canBuild") if canBuild == partTouched.Parent:FindFirstChild("canBuild") then Wall1.Size = Wall1.Size + Vector3.new(0,1,0) end end HammerHead.Touched:Connect(onTouch)
Can't guarantee this will work:
In a module script somewhere:
return { workspace.Wall1 = { MaxSize = Vector3.new(X, Y, Z), IncrementAmount = Vector3.new(0, 1, 0) }, -- and so on }
In the script:
local module = require(path.To.Module) local debounce = false hammer.Touched:Connect(function(hit) if debounce then return end; debounce = true if module[hit] then hit.Size += module[hit].IncrementAmount; hit.Size = Vector3.new(math.clamp(hit.Size.X, 0, module[hit].MaxSize.X), math.clamp(hit.Size.Y, 0, module[hit].MaxSize.Y), math.clamp(hit.Size.Z, 0 module[hit].MaxSize.Z)) end wait(3) debounce = false end)