Why does my upgrade shop break in multiplayer?
Local script (Button)
01 | local button = script.Parent |
02 | local plr = game.Players.LocalPlayer |
03 | local processEvent = workspace:WaitForChild( "processEvent" ) |
06 | button.Activated:Connect( function () |
09 | local process = function () |
11 | processEvent:FireServer(plr, cost, Type) |
12 | print ( "plr, cost, type = " .. plr.Name,cost,Type) |
15 | local guiUpdate = function () |
A part of the leaderstats script
02 | processEvent.OnServerEvent:Connect( function (plr, plr, cost, Type) |
04 | if Type = = "Jump" and tf = = true then |
07 | if game.Players:WaitForChild(plr.Name):WaitForChild( "leaderstats" ):WaitForChild( "Coins" ).Value > = cost*game.Players:WaitForChild(plr.Name):WaitForChild( "Folder" ):WaitForChild( "JumpLevel" ).Value then |
08 | game.Players:WaitForChild(plr.Name):WaitForChild( "leaderstats" ):WaitForChild( "Coins" ).Value = game.Players:WaitForChild(plr.Name):WaitForChild( "leaderstats" ):WaitForChild( "Coins" ).Value - game.Players:WaitForChild(plr.Name):WaitForChild( "Folder" ):WaitForChild( "JumpLevel" ).Value*cost |
09 | game.Players:WaitForChild(plr.Name):WaitForChild( "Folder" ):WaitForChild( "JumpLevel" ).Value = game.Players:WaitForChild(plr.Name):WaitForChild( "Folder" ):WaitForChild( "JumpLevel" ).Value + 1 |
10 | game.Players:WaitForChild(plr.Name):WaitForChild( "Folder" ):WaitForChild( "JumpPower" ).Value = 50 + 3 * game.Players:WaitForChild(plr.Name):WaitForChild( "Folder" ):WaitForChild( "JumpLevel" ).Value |
11 | workspace:WaitForChild(plr.Name).Humanoid.JumpPower = game.Players:WaitForChild(plr.Name):WaitForChild( "Folder" ):WaitForChild( "JumpPower" ).Value |
All the values get multiplied by the number of players (I think) but I'm not sure how to fix it.