FOREWARNING: The script is kind of ugly but if you can look past that, I would seriously like help with this question. This was just the only way I knew how to do it.
I have a script on the server that determines when a player touches a block and scales them accordingly however when I test it ingame I get this error:
00:23:39.159 - ServerScriptService.touchedEvent:51: attempt to perform arithmetic on local 'headScale' (a userdata value)
I'm exactly sure what this means but all need to do is be able to change this value on the server.
Script on the server:
local rs = game:GetService("ReplicatedStorage")
local remote = rs:WaitForChild("touchedEvent")
remote.OnServerEvent:Connect(function(player, part)
--get player model
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
--get scale values
local headScale = humanoid:WaitForChild("HeadScale")
local dScale = humanoid:WaitForChild("BodyDepthScale")
local wScale = humanoid:WaitForChild("BodyWidthScale")
local hScale = humanoid:WaitForChild("BodyHeightScale")
-- get player parts **PLEASE IGNORE I KNOW IT'S BAD**
local cHead = character:WaitForChild("Head")
local cUTorso = character:WaitForChild("UpperTorso")
local cRULeg = character:WaitForChild("RightUpperLeg")
local cRUArm = character:WaitForChild("RightUpperArm")
local cRLLeg = character:WaitForChild("RightLowerLeg")
local cRLArm = character:WaitForChild("RightLowerArm")
local cRHand = character:WaitForChild("RightHand")
local cRFoot = character:WaitForChild("RightFoot")
local cLTorso = character:WaitForChild("LowerTorso")
local cLULeg = character:WaitForChild("LeftUpperLeg")
local cLUArm = character:WaitForChild("LeftUpperArm")
local cLLLeg = character:WaitForChild("LeftLowerLeg")
local cLLArm = character:WaitForChild("LeftLowerArm")
local cLHand = character:WaitForChild("LeftHand")
local cLFoot = character:WaitForChild("LeftFoot")
--begin awful math part
--define part i touched
local touched = part
--define object volume
local objectVolume = (touched.Size.X * touched.Size.Y * touched.Size.Z)
print ("Object volume is "..objectVolume)
--define current player volume **PLEASE IGNORE I KNOW IT'S BAD**
local currentPlayerVolume = (cHead.Size.X * cHead.Size.Y * cHead.Size.Z) + (cUTorso.Size.X * cUTorso.Size.Y * cUTorso.Size.Z) + (cRULeg.Size.X * cRULeg.Size.Y * cRULeg.Size.Z) + (cRUArm.Size.X * cRUArm.Size.Y * cRUArm.Size.Z) + (cRLLeg.Size.X * cRLLeg.Size.Y * cRLLeg.Size.Z) + (cRLArm.Size.X * cRLArm.Size.Y * cRLArm.Size.Z) + (cRHand.Size.X * cRHand.Size.Y * cRHand.Size.Z) + (cRFoot.Size.X * cRFoot.Size.Y * cRFoot.Size.Z) + (cLTorso.Size.X * cLTorso.Size.Y * cLTorso.Size.Z) + (cLULeg.Size.X * cLULeg.Size.Y * cLULeg.Size.Z) + (cLUArm.Size.X * cLUArm.Size.Y * cLUArm.Size.Z) + (cLLLeg.Size.X * cLLLeg.Size.Y * cLLLeg.Size.Z) + (cLLArm.Size.X * cLLArm.Size.Y * cLLArm.Size.Z) + (cLHand.Size.X * cLHand.Size.Y * cLHand.Size.Z) + (cLFoot.Size.X * cLFoot.Size.Y * cLFoot.Size.Z)
print("Player volume is "..currentPlayerVolume)
--define the value to be added to the player scales
local scaleAdd = ((objectVolume / currentPlayerVolume)^(1/3))
print("Scale value to add is "..scaleAdd)
--update scale values
headScale = headScale + scaleAdd
dScale = dScale + scaleAdd
wScale = wScale + scaleAdd
hScale = hScale + scaleAdd
print("Player volume now is "..currentPlayerVolume)
end)
The print commands are there as tests to make sure everything is working correctly and it is except for getting the error when I modify the scale values.
And yes, I know it's super ugly but it's like a proof of concept for me to see if I could do it.

1 comment
omg, im reading over the script just now and yeah i think im just dumb lol. thanks for the response