I can't Subtract money from player's currency?
I have a shop and these scripts. My problem is the money won't subtract. The event I have setup is not firing which is the main problem. If there is a way easier way, someone plz tell me. There are no errors in the output.
Script in ServerScriptService
1 | local remote 1 = Instance.new( 'RemoteEvent' ) |
2 | remote 1. Name = 'Subtract' |
3 | remote 1. Parent = game:GetService( 'ReplicatedStorage' ) |
Script that is Child of PlayerGui
01 | local remote = game.ReplicatedStorage:WaitForChild( 'Subtract' ) |
03 | remote.OnServerEvent:Connect( function (player) |
05 | local cost = script.Parent:WaitForChild( 'Weapon Shop' ).Frame.Frame.Cost.Text |
06 | print ( 'You had ' ..player.leaderstats.SeerBux.Value) |
07 | player.leaderstats.SeerBux.Value = player.leaderstats.SeerBux.Value - tonumber (cost) |
08 | print ( 'You now have ' ..player.leaderstats.SeerBux.Value) |
09 | print (cost.. ' was Subtracted' ) |
10 | print ( 'Subtract Successful' ) |
Local Script under buy button (Inside a GUI); lines 7 & 19 are what fire the server when the button is clicked
01 | local but = script.Parent |
02 | plr = game.Players.LocalPlayer |
03 | local bag = plr:WaitForChild( 'Backpack' ) |
07 | local tog = game.ReplicatedStorage:WaitForChild( 'Subtract' ) |
09 | but.MouseButton 1 Click:Connect( function () |
10 | print ( 'function start :)' ) |
11 | price = but.Parent.Cost.Text |
12 | price = tonumber (price) |
13 | tool = but.Parent.ItemName.Text |
14 | bux = plr.leaderstats.SeerBux.Value |
17 | print ( 'That costs ' ..price) |
18 | print ( 'You had ' ..bux) |
20 | print ( 'You now have ' ..bux) |
21 | local Tool = game.ReplicatedStorage.Tool:WaitForChild(tool) |
23 | print ( 'Tool Found :)' ) |
24 | local ToolGive = Tool:Clone() |
27 | print ( 'Tool Not Located :(' ) |
30 | print ( 'Not Enough Money :(' ) |
31 | print ( 'You Need ' ..price) |