Can Scale To() work in a local script?

Hi, I have a grab script and I want to grab models with the possibility of enlarging them.
So I was wondering if it was possible to use ScaleTo() directly in a local script or if I was forced to use a remote event.
Thanks for help!

1 Like

I’m not good in coding, but I think that local script will only use scaleto in client side.

I’m probably wrong

3 Likes

It’s strange because when I adding a Vector 3 to the object size in the model, it works.
But when I do it directly on the model from ScaleTo(), it doesn’t work.

2 Likes

Sorry, but are you trying to scale the model or the object itself?

1 Like

I want to enlarge the model. Because the size of the object is not precise when I change it with a vector.

1 Like

i dont know the answer, but using a local script you will only scale the object in your client, meaning that everything you do in the local script can be seen only by you

unless you use Events

3 Likes

ScaleTo only multiplies the size of the parts in the model

1 Like

Yes, I like I said before, if local script only makes change client side. If you are using local scripts, you have to use bindable events to make changes server side

local Event = --Reference the event

Event:FireServer
local Event = --Reference the event
local Model = --Reference the model

--

Event.OnServerEvent:Connect(function()
	Model:ScaleTo(Number to multiply part sizes by)
end)
1 Like

It depends on what you are trying to achieve, :ScaleTo() will work on the client but it will not replicate to the other clients, if you want everyone to see it then you either have to make the script server side or you have to use a remote event,

I’m not sure what you mean by this but the way :ScaleTo() works is you pass a number and it multiplies the original scale by that number, so if you have a model that is 5x5x5 and you do :ScaleTo(2) then it will become 10x10x10 and if you do :ScaleTo(1.5) after then it will be 7.5x7.5x7.5

1 Like

Thanks everyone for your answers!
But I have now a another problem, the block becomes “capricious” with this method…

Context:
I have a script allowing you to grab objects, the object is located at the mouse position.
More the object is far of the player, more the object is big.

But now the object no longer wants to follow my mouse

Video:
robloxapp-20240708-1604450.wmv (1,0 Mo)

Thanks

1 Like

Are you running it on the server or the client? Last time I worked with :ScaleTo() it was very laggy when running it from the server and would freeze the player, try running it locally or just manually changing the sizes.

1 Like

ScaleTo() is located in a script and is activated by a remote event coming from a local script.

exemple of local script:

local pos = mouse.Hit.Position
			target.BodyPosition.Position = pos
			
			local distance = (player.Character.HumanoidRootPart.Position - target.Position).Magnitude
			local size = target.Size + Vector3.new(distance, distance, distance)        
				
			re2:FireServer(target, size, distance)

exemple of script :

game.ReplicatedStorage:WaitForChild("ScaleRE").OnServerEvent:Connect(function(player, target, size, distance)
	
target.Parent:ScaleTo(distance/100)
end)
1 Like

To resize it without lag and replicate it across all clients you could do something like this:
Client fires Remote Event > Server does :FireAllClients() > Clients receive Event and resize the part locally.

Then once the player is done moving the model you can sent another Event to resize it on the server

1 Like

I must have done it wrong, it didn’t work

local script:

local pos = mouse.Hit.Position
			target.BodyPosition.Position = pos
			
			local distance = (player.Character.HumanoidRootPart.Position - target.Position).Magnitude
			local size = target.Size + Vector3.new(distance, distance, distance)        
				
			re2:FireServer(target, size, distance)
			
			re2.OnClientEvent:Connect(function(newsize)
				target.Parent:ScaleTo(newsize)
			end)

script:

game.ReplicatedStorage:WaitForChild("ScaleRE").OnServerEvent:Connect(function(player, target, size, distance)

	target.Parent:ScaleTo(distance/100)
	
	local newsize = target.Parent:GetScale()
	
	game.ReplicatedStorage.ScaleRE:FireAllClients(newsize)
end)
1 Like

Remove this from the server script

And change it to this:
game.ReplicatedStorage.ScaleRE:FireAllClients(distance/100)

Then you can have a separate remote event to scale it on the server once the player is done dragging it

1 Like

I don’t know why but the block no longer grows as it is moved

1 Like

Are there any errors in the output?

1 Like

No, there are none, i dont understand

1 Like

I created another script without using ScaleTo() and it worked, for those interested come pm