So I have a game which when you open a case, you get a random amount of coins. But, the game doesn't do this. Anyone know why? Here is my local script, inside the button.

local de = 1
local price = 100
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Click:Connect(function()
	if player.leaderstats.Coins.Value >= 100 then
	if de == 1 then
		
	de = 0
game.ReplicatedStorage.SellCoins:FireServer(price)
script.Parent.Parent.Parent.Visible = false
local a = require(game.Players.LocalPlayer("WaitForChild","PlayerGui")("WaitForChild","Modules")("WaitForChild","case")):create("Classic")
print(a)
if a == "Some Coins" then
	local givecash = 10
	game.ReplicatedStorage.CoinsWon:FireServer(givecash)
elseif a == "Same Coins" then
	local givecash = 100
	game.ReplicatedStorage.CoinsWon:FireServer(givecash)
elseif a == "Lots of Coins" then
	local givecash = 500
	game.ReplicatedStorage.CoinsWon:FireServer(givecash)
	elseif a == "Jackpot" then
	local givecash = 1000
	game.ReplicatedStorage.CoinsWon:FireServer(givecash)
end


wait(3)

de = 1

	end
	end
end)

Here is my server script:

game.ReplicatedStorage.CoinsWon.OnServerEvent:Connect(function(plr, a)
	
	
		plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + a

	

		end)
		game.ReplicatedStorage.SellCoins.OnServerEvent:Connect(function(plr, price)
			plr.leaderstats.Coins.Value =plr.leaderstats.Coins.Value - price
		end)

3 comments

0

You shouldn't trust the client with what you are, you should fire to the server that they're opening a case or selling coins, and have the server fire back with the reward they won if they had a case, or the case if they had enough coins to buy it. Is output giving any errors? Does it get to line 12? Does the server script run line 04 when the even fires?

0

Yes, it does print it. But, it never fires I think.

0

I had to just use tostring(). :)