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

How to make a parts size go down by increments when its clicked?

Hi, I'm trying to make a system where when the player has the tool "Bucket" equipped and they click on the water, the water's size will go down by increments of -1. But the script as expected would make the water's Y coordinate switch to the smallest size a part can go (0.05.) If somebody could please help me that would be great! Thanks!

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Bucket = script.Parent

Bucket.Activated:Connect(function()
	if Mouse.Target.Name == "Water" then
		Mouse.Target.Size = Vector3.new(94.93,-1,134.44)
	end
end)

1 answer

✓ Accepted answer

You should add -1 to the value, and not set the value to -1. it's impossible to set a Y size to -1, so roblox set it to the smallest possible value, so 0.05.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Bucket = script.Parent
 
Bucket.Activated:Connect(function()
	if Mouse.Target.Name == "Water" then
		Mouse.Target.Size = Mouse.Target.Size + Vector3.new(0,-1,0) -- changed X and Z to 0, else it will add 94.93 to the part's X size and 134.44 to the part's Z size.
	end
end)

3 comments

0

Also if you change the size of the part, it will change in the both Y sides (if you change the size or a part, the part's position won't change)

0

you can add " Mouse.Target.Position = Mouse.Target.Position + Vector3.new(0, -0.5, 0)

0

hope this helped

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