Sell area not converting storage to Coins

Hello developer so I have this sell area and when the player steps on it all his storage will convert to coins
but the storage is not converting to coins and then when I ran the print statement on line 9 the output prints 0 but it should print 17
21:07:17.936 0 - Server - Script:9
Screenshot 2021-09-21 211129
look the value is 17 but the output prints 0


here is a video

normal script inside the red sell part

local Sell = script.Parent
local Players = game:GetService("Players")

Sell.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then 
		local player = Players:GetPlayerFromCharacter(hit.Parent)
		if not player then return end
		print(player.Name .. " pressed me!")
		print(player.leaderstats.Storage.Value)-- LINE 9
	end	
	
	
end)

Are you changing the value in a local script or a server script? if you are changing the value in a localscript, it will not replicate to the server. But you can use an RemoteEvent | Roblox Creator Documentation to replicate that change to the server.

I am changing the value in a server script

Can you show the script that changes the value? also try printing the value of that intvalue in a localscript

local EmptyCup = script.Parent
local plr = game.Players.LocalPlayer
local ToolUi = game.Players.LocalPlayer.PlayerGui:WaitForChild("ToolUi")
local Im = ToolUi.ImageLabel
local TweenService = game:GetService("TweenService")



local mouse = plr:GetMouse()
EmptyCup.Activated:Connect(function()
	wait(0.1)
	if plr.leaderstats.Storage.Value >= 25 then
	plr.leaderstats.Storage.Value = 25 
	-- Make a sell Button Pop up  
	return 

	end
	wait(1)
	plr.leaderstats.Storage.Value = plr.leaderstats.Storage.Value + 1

	local ImClone = Im:Clone()
	ImClone.Parent = ToolUi
	local Rand = math.random(1,5)
	print(Rand)
	if Rand == 1 then 
		ImClone.Position = UDim2.new(0.16,0,0.8, 0)
		ImClone.Name = "ImClone1"
		
		ImClone:TweenPosition(
		UDim2.new(0.16, 0,-0.3, 0),
		"Out",
		"Bounce",
		2,
		true,
		nil
		)
		
		
		
	
	
	elseif Rand == 2 then
		ImClone.Position = UDim2.new(0.32,0,0.8, 0)
		ImClone.Name = "ImClone2"
	
		
		ImClone:TweenPosition(
			UDim2.new(0.32, 0,-0.3, 0),
			"Out",
			"Bounce",
			2,
			true,
			nil
		)
	
	elseif Rand == 3 then 
		ImClone.Position = UDim2.new(0.48,0,0.8, 0)
		ImClone.Name = "ImClone3"
		
		ImClone:TweenPosition(
			UDim2.new(0.48, 0,-0.3, 0),
			"Out",
			"Bounce",
			2,
			true,
			nil
		)

	elseif Rand == 4 then 
		ImClone.Position = UDim2.new(0.64,0,0.8, 0)
		ImClone.Name = "ImClone4"
		
		ImClone:TweenPosition(
			UDim2.new(0.64, 0,-0.3, 0),
			"Out",
			"Bounce",
			2,
			true,
			nil
		)

	
	elseif Rand == 5 then 
		ImClone.Position = UDim2.new(0.80,0,0.8, 0)
		ImClone.Name = "ImClone5"
		
		ImClone:TweenPosition(
			UDim2.new(0.80, 0,-0.3, 0),
			"Out",
			"Bounce",
			2,
			true,
			nil
		)
	end
	
end)

here is the script that changes the value when the player clicks the tool the Activated event fires and all of these other things happen

Well then the server prints 0 of that int value because you are changing it from a local script. changes from a local script are not replicated to the server, so only the client can see those changes. But you can use an RemoteEvent | Roblox Creator Documentation to tell the server to make the changes.

oooooh I understand now, Thank you, and you are a very good scripter btw.

1 Like