How come the value returns zero?

Here is my serverscript:

local guiChanged = game.ReplicatedStorage.guiChanged

guiChanged.OnServerEvent:Connect(function(player)
print(player.PlayerGui.BoodyGrower.Counter.Amount.Value)
print(player.Name)
player.Character.Head.BillboardGui.TextLabel.Text = player.PlayerGui.BoodyGrower.Counter.Amount.Value
end)

Here is my local script:

local amount = script.Parent.Amount

local Value = amount.Value

local text = script.Parent

local guiChanged = game.ReplicatedStorage.guiChanged

local player = game.Players.LocalPlayer

amount.Changed:Connect(function()

text.Text = amount.Value

guiChanged:FireServer(player)

end)

Any Idea why the print value returns zero in the serverscript?

You don’t need to fire the player as the first argument, but it seems this won’t fix anything right now.

You are probably changing the value in a local script. Can you send the script that changes the value!

then what do i fire?
//////////////

sure

local text = script.Parent
local growBoodyEvent = game.ReplicatedStorage.BoodyGrow
local player = game.Players.LocalPlayer
local clickSound = text.Parent.Click
local growSound = text.Parent.Grow
local textSize = text.Size
local debounce = false
local counter = text.Parent.Counter

text.MouseButton1Click:Connect(function()
if not debounce then
debounce = true
counter.Amount.Value += 1
growBoodyEvent:FireServer(player)
clickSound:Play()
growSound:Play()
text:TweenSize(UDim2.new(0, 81,0, 72), “Out”, “Sine”, 0.2)
wait(0.2)
text:TweenSize(UDim2.new(0, 57,0, 54), “In”, “Sine”, 0.2)
wait(0.5)
debounce = false
end
end)

this is where it changes and this is a local script

so do i change it in a serverscript?

So you’re changing the counter value on the client, therefore the server still sees it as zero. Maybe you can send the counter value through the remote? Just make sure to remove the player argument in FireServer.

the problem here is you are updating the value in the local script and not a server script. The server will still see the value as 0 while the client will see it as what it’s meant to be. To fix this you must use a remote event to change the value.

okay, ill put it into my serverscript

works good now thank you guys!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.