script.Parent.Touched:Connect(function(f)
if game.Players:GetPlayerFromCharacter(f.Parent) then
local plr = game.Players:GetPlayerFromCharacter(f.Parent)
local chr = plr.Character or plr.CharacterAdded:Wait()
chr:BreakJoints()
end
end)
script.Parent:Resize(Enum.NormalId.Front, 50)
the code above is for a part that i want to resize it to 50 studs at it’s front surface. this does work all the time when it’s NOT collidable. however, if this part has a touched event, like above…then it cannot penetrate through any part/wall that gets in its way during resizing (it does not resize at all; this code wouldn’t work if something is in the way in the part’s lookvector direction). i have no idea why this is happening. is there really a solution to this so that it works ALL the time?
oh and also, if any part that gets in its way HAS a touched event, then the resizing part cannot also penetrate through it.
(i honestly don’t think there is a way. i did look for help but…nothing relevant)
i mean…that does work. yeah, i can do that…but changing the size property changes both sides of an axis (e.g. y value has both the top and bottom surfaces changed).
Resize() only changes one side of a surface, which would look more better perhaps
(i’ll send a video about what i am actually trying to achieve)
You’d have to recreate the :Resize() function with code, :Resize() checks for any overlapping parts before resizing, and if there are overlapping parts, it doesn’t resize.
Small code example:
local function resize(target: BasePart, normal: Enum.NormalId, amount: number)
local vectorNormal = Vector3.FromNormalId(normal) * amount
target.Size += vectorNormal:Abs() --vectorNormal could be negative and squish the part
target.CFrame *= CFrame.new(vectorNormal / 2) --fixes rotation issues
end
resize(script.Parent, Enum.NormalId.Front, 50)
oh. i was thinking of recreating that at some point
but anyways that code sample does seem to resolve that issue. thanks!
(unfortunately i cannot send the video for some reason but i’ll at least mark this as a solution. thank you in advance…!)