This is the code:
--Variables-- local Purchase_Req = game.ReplicatedStorage.Replicators.Shop.Purchase_req local Audio_Controller = game.ReplicatedStorage.Replicators.Misc.Audio_Controller local Hammer = game.ReplicatedStorage.Tools.Hammer:Clone() local Purchase = "Purchase_Sound" local Err_Sound = "Err_Sound" local deb = false --<--->-- Purchase_Req.OnServerEvent:Connect(function(player,tool) --local variables-- local Currency = player:WaitForChild("Currency") local Bits = Currency.Bits local Own_Hammer = player:WaitForChild("ToolStat").Hammer if not deb then deb = true print("under deb") if tool == "Hammer" then if Bits.Value >=10 and Own_Hammer.Value == false then Own_Hammer.Value = true Bits.Value = Bits.Value -10 Hammer.Parent = player.Backpack Audio_Controller:FireClient(player,Purchase) elseif Bits.Value <10 or Own_Hammer.Value == true then print("Wrong elseif stateent") Audio_Controller:FireClient(player,Err_Sound) end print("run") --This one-- if tool == "Shovel" then print("Shovel") end end end wait(1) deb = false end)
It seems you got confused with the tabbing and forgot an elseif by the tool. I think I also got rid of an extra end. I think this is what you're wanting to do:
Try this:
--Variables-- local Purchase_Req = game.ReplicatedStorage.Replicators.Shop.Purchase_req local Audio_Controller = game.ReplicatedStorage.Replicators.Misc.Audio_Controller local Hammer = game.ReplicatedStorage.Tools.Hammer:Clone() local Purchase = "Purchase_Sound" local Err_Sound = "Err_Sound" local deb = false --<--->-- Purchase_Req.OnServerEvent:Connect(function(player,tool) --local variables-- local Currency = player:WaitForChild("Currency") local Bits = Currency.Bits local Own_Hammer = player:WaitForChild("ToolStat").Hammer if not deb then deb = true print("under deb") if tool == "Hammer" then if Bits.Value >=10 and Own_Hammer.Value == false then Own_Hammer.Value = true Bits.Value = Bits.Value -10 Hammer.Parent = player.Backpack Audio_Controller:FireClient(player,Purchase) elseif Bits.Value <10 or Own_Hammer.Value == true then print("Wrong elseif stateent") Audio_Controller:FireClient(player,Err_Sound) end print("run") --This one-- elseif tool == "Shovel" then print("Shovel") end end wait(1) deb = false end)
Definitely make use of the tabbing, it will help you line up your if statements. Most people on here won't help you if the code isn't properly formatted (tabbing in code blocks). I actually had to open up a blank studio and tab it myself before I could see the problem. I'm not harping on you or anything, it's just something you need to know if you want to increase the chances of receiving help.