Why doesnt my script work

so i wanted to make money converter and wrote this script:

local player = game.Players.LocalPlayer
local frame = script.Parent
local ftoc = frame.ConvertFtoC
local ctor = frame.ConvertCtoR
local rtof = frame.ConvertRtoF
local rtoc = frame.ConvertRtoC
local ctof = frame.ConvertCtoF
local ftor = frame.ConvertFtoR

ftoc.MouseButton1Click:Connect(function()
	if player.leaderstats.Fosh.Value == 1 or player.leaderstats.Fosh.Value >= 1 then
		player.leaderstats.Fosh.Value = player.leaderstats.Fosh.Value - 1
		player.leaderstats.Cats.Value = player.leaderstats.Cats.Value + 45
	end
end)

ctor.MouseButton1Click:Connect(function()
	if player.leaderstats.Cats.Value == 1 or player.leaderstats.Cats.Value >= 1 then
		player.leaderstats.Cats.Value = player.leaderstats.Cats.Value - 1
		player.leaderstats.Rubles.Value = player.leaderstats.Rubles.Value + 2
	end
end)

rtof.MouseButton1Click:Connect(function()
	if player.leaderstats.Rubles.Value == 90 or player.leaderstats.Rubles.Value >= 90 then
		player.leaderstats.Rubles.Value = player.leaderstats.Rubles.Value - 90
		player.leaderstats.Fosh.Value = player.leaderstats.Fosh.Value + 1
	end
end)

rtoc.MouseButton1Click:Connect(function()
	if player.leaderstats.Rubles.Value == 2 or player.leaderstats.Rubles.Value >= 2 then
		player.leaderstats.Rubles.Value = player.leaderstats.Rubles.Value - 2
		player.leaderstats.Cats.Value = player.leaderstats.Cats.Value + 1
	end
end)

ctof.MouseButton1Click:Connect(function()
	if player.leaderstats.Cats.Value == 45 or player.leaderstats.Cats.Value >= 45 then
		player.leaderstats.Cats.Value = player.leaderstats.Cats.Value - 45
		player.leaderstats.Fosh.Value = player.leaderstats.Fosh.Value + 1
	end
end)

ftor.MouseButton1Click:Connect(function()
	if player.leaderstats.Fosh.Value == 1 or player.leaderstats.Fosh.Value >= 1 then
		player.leaderstats.Fosh.Value = player.leaderstats.Fosh.Value - 1
		player.leaderstats.Rubles.Value = player.leaderstats.Rubles.Value + 90
	end
end)

and it doesnt work, it is local script also here’s the structure
image

1 Like

Changes you make to leaderstats through a local script will not be reflected to the server. You need to set up a remote event to manipulate the leaderstats value with a server script.

I noticed a couple other redundancies in your code. One such example is writing the following:

player.leaderstats.Fosh.Value == 1 or player.leaderstats.Fosh.Value >= 1

This is fundamentally the same as:
player.leaderstats.Fosh.Value >= 1

On a different note, it’d be appreciated if you edited your title to be more descriptive.

3 Likes