This script calls a RemoteEvent, which works.

Then checks if a players money is more then their plots maximum money capacity.

This script works almost perfectly!

rs.MoneyChangeEvent.OnServerEvent:Connect(function(player, leaderstats)
	local plr = game.Players:GetPlayerFromCharacter(game.Workspace:FindFirstChild(player.Name))
	print(3)
	local function firerepstore()
		if leaderstats.Value > script.Parent:FindFirstChild(Plot).Storage.Value then
			print("Almost!")
			leaderstats.Value = script.Parent:FindFirstChild(Plot).Storage.Value
			print("Complete!")
		end
		print(6)
	end
	print(4)
	if script.Parent.Plot1.Owner.Value == player.Name then
		Plot = "Plot1"
		firerepstore()
		print(4)
	elseif script.Parent.Plot2.Owner.Value == player.Name then
		Plot = "Plot2"
		firerepstore()
		print(5)
	end
end)

I get an issue on this line.

		if leaderstats.Value > script.Parent:FindFirstChild(Plot).Storage.Value then
			print("Almost!")
			leaderstats.Value = script.Parent:FindFirstChild(Plot).Storage.Value
			print("Complete!")
		end

For some reason this worked once, but hasn't worked since.

P.S: All the prints() with numbers in them are called!

Any help would be nice. Thanks!

15 comments

0

Whats the issue? You need to explain whats not working, not just say theres an issue.

0

Line 5

0

When It asks if leaderstats.Money is more then Storage.Value. The line should work, but doesnt. Why is that?

0

print both of those values before the if statement runs, and see what you get.

0

The GetPlayerFromCharacter line isn't needed here when you have the player in the first parameter of OnServerEvent. There isn't much information to go by here and it seems some code is missing.

1

Since you use the string set to Plot on line 14 you could instead pass it to firerespstore() as an argument.

0

Hes probably got a bad reference to a value. Im sure him printing them will help determine whats gone wrong.

0

I have like a million prints lol

0

I don't think plot has been defined yet becuase a script run down

0

Ok?

0

Ok so here's a question... what is the argument 'leaderstats'? If it's what I'm assuming it is, it's some form of value instance that contains other value instances that determines your leaderboard, right? So leaderstats.Value wouldn't return anything useful. It would need to be like leaderstats.Money.Value or something

0

I had the same thought, thats why i asked him to print the values, but he didnt want to i guess.

0

leaderstasts = leaderstats.Money

0

is leaderstats.Value = script.Parent:FindFirstChild(Plot).Storage.Value the second time it runs? because you're using a > operator, not a >= operator, so it wouldn't fire again if the two values are equivalent

0

Sorry Solved It Already.