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.
- The size keeps going and doesn't stop, I want the Wall1 size to stop at 0,5,0 in Vector3
- The size increases when I hit ANYTHING, not just the Wall1. I want the size to increase only when I hit Wall1 with the Hammer.
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)
