Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make it so the parts position will adjust to the parts size?

So what I have so far will subtract the parts size correctly, but will incorrectly change its position to adjust with the size change.

--local event = game.ReplicatedStorage.Remote.Mow
local event = script.Parent:WaitForChild("Events").Mow

event.OnServerEvent:Connect(function(plr, target)
	target.Size = target.Size - Vector3.new(0,0.1,0)
	target.Position = target.Position - Vector3.new(0,1,0)
end)

I'm not great at cframe so if that's why I landed here.

Thanks to whoever can take the time out of their day to fix/help me with any of my mistakes

1 answer

If you're going to shorten the length of a part by 1 unit, then you must move it by half that amount (0.5 units) in the same axis.

In your case, you are reducing the size by 0.1 units in the y axis. This means you must move it down by 0.05 units to keep the part in the same position as it was before.

9 comments

0

It may be my describing or my misunderstanding of your answer, but what I meant is how can I make it stay on the ground without de-anchoring it and re-anchoring it to stay on the ground instead of floating?

0

Yeah, exactly how I described it to ya. If you are reducing the height of the part by 0.1, then it will start floating. Move the part down by half that amount (0.05) and it will go back to the ground.

0

Well for me it decides to go up and then down and doesn't reach the ground although it may be something inside of the tools script as I haven't yet included debounce...

0

All you have to do is change the Vector3.new(0, 1, 0) to Vector3.new(0, 0.05, 0) in line 6.

0

Doing this causes this to happen? https://i.imgur.com/6325tSa.png

0

That's odd. I tested it out and it seemed to work perfectly: https://i.gyazo.com/4ba62a1c3ca05e4825ceeb5c7a415838.png . Maybe it's something else that's causing that?

0

Well, your 0.05 change worked, but implementing it into the 6th line had no help

0

but target.CFrame = CFrame.new(target.Position - Vector3.new(0,0.05,0)) did work so thank you for the support

0

That's odd. You must've had some orientation in your target part then. No problem! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.