Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
5 years ago

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.

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? VeryDarkDev 47 — 5y
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. chomboghai 2044 — 5y
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... VeryDarkDev 47 — 5y
0
All you have to do is change the Vector3.new(0, 1, 0) to Vector3.new(0, 0.05, 0) in line 6. chomboghai 2044 — 5y
View all comments (5 more)
0
Doing this causes this to happen? https://i.imgur.com/6325tSa.png VeryDarkDev 47 — 5y
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? chomboghai 2044 — 5y
0
Well, your 0.05 change worked, but implementing it into the 6th line had no help VeryDarkDev 47 — 5y
0
but target.CFrame = CFrame.new(target.Position - Vector3.new(0,0.05,0)) did work so thank you for the support VeryDarkDev 47 — 5y
0
That's odd. You must've had some orientation in your target part then. No problem! :) chomboghai 2044 — 5y
Ad

Answer this question