Ok i'm trying to do a shop script, everything is fine until the part where u need to buy the knife/weapon, Here is the code
Local Script Code (Gui):
local plr = game:GetService("Players").LocalPlayer
local VF = plr:WaitForChild("ValuesFolder")
local Coins = VF:WaitForChild("Coins")
local Diamonds = VF:WaitForChild("Diamonds")
local WeaponName = "Knife"
local WeaponType = "Melee" --//Currenty Types: Melee , Firearm
local ValueToBeOwned = "HasKnife"
local VTBO = VF[ValueToBeOwned]
local Price = 0
local PriceV = 0
local debounce = false
local gui = script.Parent
script.Parent.MouseButton1Click:Connect(function()
if not debounce then
debounce = true
local noob = plr.Backpack:FindFirstChild(WeaponName)
if Coins.Value >= Price and Diamonds.Value >= PriceV and not noob then
game.ReplicatedStorage.Remotes.BuyItem:FireServer(WeaponName,Pr ice,PriceV,WeaponType,ValueToBeOwned)
if Price.Value <= 0 then
gui.Text = "Gotcha!"
wait(1)
gui.Text = "Get"
else
gui.Text = "Purchased!"
wait(1)
gui.Text = "Buy"
end
elseif Coins.Value < Price and Diamonds.Value < PriceV then
gui.Text = "Not Enough Coins/Diamonds :("
wait(1)
if Price.Value <= 0 then
gui.Text = "Get"
else
gui.Text = "Buy"
end
elseif VTBO.Value == true then
gui.Text = "Already Owned! :D"
wait(1)
if Price.Value <= 0 then
gui.Text = "Get"
else
gui.Text = "Buy"
end
elseif noob then
gui.Text = "U Already Has One With You! >:C"
wait(1)
if Price.Value <= 0 then
gui.Text = "Get"
else
gui.Text = "Buy"
end
end
debounce = false
end
end)
Remote Event Script (Fired By Local Script):
game.ReplicatedStorage.Remotes.BuyItem.OnServerEvent:Connect(function(plr,ItemName,P,P2,WT,VTBO)
local VF = plr:WaitForChild("ValuesFolder")
local Coins = VF:WaitForChild("Coins")
local Diamonds = VF:WaitForChild("Diamonds")
local MeleeFolder = game.ReplicatedStorage.Weapons:FindFirstChild(WT)
local Weapon = MeleeFolder[ItemName]
local noob = plr.Backpack:FindFirstChild(ItemName)
local Value = VF[VTBO]
if MeleeFolder and Weapon and not noob then
if Value.Value == false then
Coins.Value = Coins.Value - P
Diamonds.Value = Diamonds.Value - P2
Weapon:Clone().Parent = plr.Backpack
end
end
end)
[SerpentineKing]: Input Proper Code Format / Indentation

1 comment
thx it worked :D