Intvalue not taking affect in client or server

I made this tool script, when you click the right arrow gui, the value will increase by 1, but this is not taking affect. Since it is parented in the player GUI, i tried using playergui for the variable but it’s not working. I also used Remote Events to call it from the server but this is still not taking any action. Any help is very appreciated!

Here is the script:

Client:
local plr = game.Players.LocalPlayer

local RightClick = plr:WaitForChild(“PlayerGui”).toolInformation.rightClick

local leftClick = plr:WaitForChild(“PlayerGui”).toolInformation.leftClick

local currentTool = plr:WaitForChild(“PlayerGui”).toolInformation.CurrentTool.Value

local RightEvent = game.ReplicatedStorage:WaitForChild(“LeftClick”)

local shop = game.ReplicatedStorage:WaitForChild(“Shop”)

local tweenService = game:GetService(“TweenService”)

local camera = workspace.CurrentCamera

local maximumItem = 9

camera.CameraType = “Scriptable”
RightClick.MouseButton1Click:Connect(function()
RightEvent:FireServer(currentTool)
local tween = tweenService:Create(
camera,
TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0),
{
CFrame = workspace:WaitForChild(“cp”…currentTool).CFrame,
Focus = workspace:WaitForChild(“cp”…currentTool).CFrame
}
)
tween:Play()
end)

Server:
game.ReplicatedStorage:WaitForChild(“RightClick”).OnServerEvent:Connect(function(plr, maximumItem)
local currentTool = plr:WaitForChild(“PlayerGui”).toolInformation.CurrentTool.Value

if currentTool < maximumItem then
	currentTool = currentTool + 1
end	

end)

The server is server-sided.
Client is client-sided.
If you try to access a playergui from the server, it will appear on the server and not the client.
Explain more about

Like what was the code that was used when you tried remote events?

Server Code: game.ReplicatedStorage:WaitForChild(“RightClick”).OnServerEvent:Connect(function(plr, maximumItem)
local currentTool = plr:WaitForChild(“PlayerGui”).toolInformation.CurrentTool.Value

if currentTool < maximumItem then
	currentTool = currentTool + 1
end

Server does not have access to PlayerGui and anything inside it, under any circumstances.

So shall I put the value somewhere else, if so, where?

I would suggest putting stuff in ReplicatedStorage.

But you can access an individual player’s PlayerGui container and its contents too once you get hold of a player through any means, on the server.

Player.PlayerScripts however isn’t replicated.

Values still remain the same.
The localscript is parented in a GUI Here:
starterGui

Updated Localscript:

local plr = game.Players.LocalPlayer
local RightClick = plr:WaitForChild(“PlayerGui”).toolInformation.rightClick
local leftClick = plr:WaitForChild(“PlayerGui”).toolInformation.leftClick
local currentTool = game.ReplicatedStorage:WaitForChild(“CurrentTool”).Value
local RightEvent = game.ReplicatedStorage:WaitForChild(“LeftClick”)
local shop = game.ReplicatedStorage:WaitForChild(“Shop”)
local tweenService = game:GetService(“TweenService”)
local camera = workspace.CurrentCamera
local maximumItem = 9
camera.CameraType = “Scriptable”
RightClick.MouseButton1Click:Connect(function()
while wait() do
if currentTool < 9 then
currentTool = currentTool + 1
else
currentTool = currentTool + 1
end
end

local tween = tweenService:Create(
	camera,
	TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0),
	{
		CFrame = workspace:WaitForChild("cp"..currentTool).CFrame,
		Focus = workspace:WaitForChild("cp"..currentTool).CFrame
	}

)
tween:Play()
end)

Two things wrong with your script:

local currentTool = game.ReplicatedStorage:WaitForChild(“CurrentTool”).Value

This simply saves the current value of CurrentTool as a variable in your script. Doing currentTool = currentTool + 1 just changes the variable, not the actual value of the Value instance. You have to save your variable as local currentTool = game.ReplicatedStorage:WaitForChild(“CurrentTool”) and always use .Value in your script.

You also still have to use RemoteEvents. Changing the value on the client won’t let the server know that it changed.

Wow, thanks so much. I didn’t even realise nor notice that!