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

Mesh scale instantly changes back to original size when I change it?

I am trying to make a hat grow bigger when the user clicks on a button but every time I make it bigger it instantly goes back to the original size.

Server Script:

script.Parent.OnServerEvent:Connect(function(player)
	local char = workspace:FindFirstChild(player.Name)
	local hat = char:FindFirstChild("StarterShag")
	local scale = hat.Handle.Mesh.Scale
	
	print(scale)
	scale = Vector3.new(scale.X+1,scale.Y+1,scale.Z+1)
	print(scale) 
end)

Local Script:

local sizeUp = workspace:WaitForChild("Remotes"):WaitForChild("SizeUp_Event")
script.Parent.MouseButton1Click:Connect(function()
	sizeUp:FireServer()
end)

1 comment

0

Couldn't you just do scale = scale + Vector3.new(1,1,1), or does that not work with hats?

1 answer

✓ Accepted answer

Dont use .Scale in variables for change's.

Here is fixed script:

-- Server:

script.Parent.OnServerEvent:Connect(function(player)
    local char = workspace:FindFirstChild(player.Name)
    local hat = char:FindFirstChild("StarterShag")
    local mesh = hat.Handle.Mesh

    print(mesh.Scale)
    mesh.Scale = Vector3.new(mesh.Scale.X+1,mesh.Scale.Y+1,mesh.Scale.Z+1) -- Or you can use mesh.Scale = mesh.Scale + Vector3.new(1,1,1)
    print(mesh.Scale)
end)

Hope it helped :D

Errors? tell-me on comments.


Solved your problems? put in tile [SOLVED] or accept a answer.

2 comments

0

Yeah, whenever you do that, it sets the variable scale to whatever the scale is at that current moment, and it doesn't update.

0

Nice answer though.

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