Why Is it not adding?

It will not add for some reason why?

local growBoodyEvent = game.ReplicatedStorage.BoodyGrow

local tweenService = game:GetService(“TweenService”)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

growBoodyEvent.OnServerEvent:Connect(function(player)
local add = math.random(25,50) / 1000
local move = (add/2)
print(move)
print(add)
local counter = player.PlayerGui.BoodyGrower.Counter
local leftBoody = player.Character.LeftBoody
local rightBoody = player.Character.RightBoody
local torso = player.Character.Torso
local Leftgoal = {Size = leftBoody.Size + Vector3.new(add,add,add)}
local Rightgoal = {Size = rightBoody.Size + Vector3.new(add,add,add)}
local RightgoalPos = {Position = rightBoody.Position + Vector3.new(0,0,move)}
local LeftgoalPos = {Position = rightBoody.Position + Vector3.new(0,0,-move)}
local LeftBoodytween = tweenService:Create(leftBoody, tweenInfo, Leftgoal)
local RightBoodytween = tweenService:Create(rightBoody, tweenInfo, Rightgoal)

LeftBoodytween:Play()
RightBoodytween:Play()

leftBoody.Attachment.CFrame += Vector3.new(0,0,-move)
rightBoody.Attachment.CFrame += Vector3.new(0,0,move)
counter.Amount.Value += add
player.leaderstats.BoodySize.Value += add
end)

What do you mean add? Any errors in the output? What do you want it to do??

Please explain more before asking for help.

This doesnt work there isnt any errors and I want it to add to a value

when i get rid of the /1000 it works but i need it there

or the math.random wouldnt work

Try this:

local growBoodyEvent = game.ReplicatedStorage.BoodyGrow

local tweenService = game:GetService(“TweenService”)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

growBoodyEvent.OnServerEvent:Connect(function(player)
local randint = math.random(25,50)
local add = randint/1000
local move = (add/2)
print(randint)
print(move)
print(add)
local counter = player.PlayerGui.BoodyGrower.Counter
local leftBoody = player.Character.LeftBoody
local rightBoody = player.Character.RightBoody
local torso = player.Character.Torso
local Leftgoal = {Size = leftBoody.Size + Vector3.new(add,add,add)}
local Rightgoal = {Size = rightBoody.Size + Vector3.new(add,add,add)}
local RightgoalPos = {Position = rightBoody.Position + Vector3.new(0,0,move)}
local LeftgoalPos = {Position = rightBoody.Position + Vector3.new(0,0,-move)}
local LeftBoodytween = tweenService:Create(leftBoody, tweenInfo, Leftgoal)
local RightBoodytween = tweenService:Create(rightBoody, tweenInfo, Rightgoal)

LeftBoodytween:Play()
RightBoodytween:Play()

leftBoody.Attachment.CFrame += Vector3.new(0,0,-move)
rightBoody.Attachment.CFrame += Vector3.new(0,0,move)
counter.Amount.Value += add
player.leaderstats.BoodySize.Value += add
end)

still doesnt work i honeslty have no clue why

this is a serverscript so it should work

Oh, I found out why…

In this line,

local counter = player.PlayerGui.BoodyGrower.Counter

You are trying to access the PlayersGui in a SERVER script, and long story short, you can’t do that.

Try making this a local script and change what is needed, or make a new RemoteEvent that is fired when you want to change the BoodyGrower.Counter value in the GUI.

i get the player from a remote event

growBoodyEvent.OnServerEvent:Connect(function(player)

it worked before with whole numbers just not with decimals

Yes, but you’re still changing it in a server script, which, if I am mistaken, does not work.

It does tho. lol It literally works

1 Like