So i got a script and i want it to determine whether the player has a level 1 permit or a level 2 permit, level 2’s can buy all the guns, while level 1’s are limited to certain, but my script wont work even as a level 1, or a level 2, any help?
script.Parent.MouseButton1Click:Connect(function()
local Plr = game.Players:FindFirstChild(script.Parent.Parent.Parent.Parent.Parent.Parent.PersonUsing.Value)
if Plr.stats.Cash.Value >= script.Parent.Price.Value then
if Plr.stats.GunPermit.Value == script.Parent.Level.Value or Plr.stats.GunPermit.Value == 2 then
local What = script.Parent.What:Clone()
local Price = script.Parent.Price:Clone()
Price.Parent = What
What.Parent = script.Parent.Parent.Parent.MyOrder
local GunCart = script.Gun:Clone()
GunCart.GunName.Text = script.Parent.What.Value
GunCart.Price.Text = "$"..script.Parent.Price.Value
GunCart.Level.Text = "$"..script.Parent.Level.Value
GunCart.Parent = script.Parent.Parent.Parent.Parent.Checkout
script.Parent.Parent.Parent.Total.Value = script.Parent.Parent.Parent.Total.Value + script.Parent.Price.Value
end
else
local c = game.ReplicatedStorage.GuiStuff:FindFirstChild("Cash/Rep"):Clone()
local Debris = game:GetService("Debris")
c.Parent = Plr.PlayerGui.Notify.Frame
c.Text.Text = "Insufficient Funds or not high enough permit"
c.Text.TextColor3 = Color3.new(1, 0, 0) ---- #2eff00 for green | #ff0000 for red
Debris:AddItem(c, 5)
end
end)
and also how could i reattach it into the line checking cash?
I don’t think or statements work this way, try adding an elseif statement in the original statement:
script.Parent.MouseButton1Click:Connect(function()
local Plr = game.Players:FindFirstChild(script.Parent.Parent.Parent.Parent.Parent.Parent.PersonUsing.Value)
if Plr.stats.Cash.Value >= script.Parent.Price.Value then
if Plr.stats.GunPermit.Value == script.Parent.Level.Value then
local What = script.Parent.What:Clone()
local Price = script.Parent.Price:Clone()
Price.Parent = What
What.Parent = script.Parent.Parent.Parent.MyOrder
local GunCart = script.Gun:Clone()
GunCart.GunName.Text = script.Parent.What.Value
GunCart.Price.Text = "$"..script.Parent.Price.Value
GunCart.Level.Text = "$"..script.Parent.Level.Value
GunCart.Parent = script.Parent.Parent.Parent.Parent.Checkout
script.Parent.Parent.Parent.Total.Value = script.Parent.Parent.Parent.Total.Value + script.Parent.Price.Value
end
elseif Plr.stats.GunPermit.Value == 2 then
local What = script.Parent.What:Clone()
local Price = script.Parent.Price:Clone()
Price.Parent = What
What.Parent = script.Parent.Parent.Parent.MyOrder
local GunCart = script.Gun:Clone()
GunCart.GunName.Text = script.Parent.What.Value
GunCart.Price.Text = "$"..script.Parent.Price.Value
GunCart.Level.Text = "$"..script.Parent.Level.Value
GunCart.Parent = script.Parent.Parent.Parent.Parent.Checkout
script.Parent.Parent.Parent.Total.Value = script.Parent.Parent.Parent.Total.Value + script.Parent.Price.Value
end
else
local c = game.ReplicatedStorage.GuiStuff:FindFirstChild("Cash/Rep"):Clone()
local Debris = game:GetService("Debris")
c.Parent = Plr.PlayerGui.Notify.Frame
c.Text.Text = "Insufficient Funds or not high enough permit"
c.Text.TextColor3 = Color3.new(1, 0, 0) ---- #2eff00 for green | #ff0000 for red
Debris:AddItem(c, 5)
end
end)