I created a Gear Store. and also created a badge where if the player has earned a Badge, then the player will get a free Item from that Badge. but I have a problem. where when I try it the “Get” writing will disappear into “Equip” but this is not,
How to overcome this?
-
Video
So where does the script or LocalScript go wrong?
localScript Texte
local groupinfo = game:GetService("BadgeService")
while true do
wait()
local Info = script.Parent.A.Info.Frame
local Tag = Info.NamaAlat.Text
local rep = game.ReplicatedStorage.AlatMain:FindFirstChild(Tag)
local isInGroup = nil
local isInBadge = nil
if rep and rep.Price:FindFirstChild("Group") then
local groupinfo = game:GetService("GroupService"):GetGroupInfoAsync(rep.Price.Group.Value)
isInGroup = game.Players.LocalPlayer:IsInGroup(rep.Price.Group.Value)
Info.UntukGrup.Image = groupinfo.EmblemUrl
end
if rep and rep.Price:FindFirstChild("BadgeV") then
local groupinfo = game:GetService("BadgeService"):GetBadgeInfoAsync(rep.Price.BadgeV.Value)
isInBadge = game.Players.LocalPlayer:FindFirstChild("BadgeV")
end
if game.Players.LocalPlayer.Tags:FindFirstChild(Tag) then
if game.Players.LocalPlayer.Tags[Tag].Value == true and game.Players.LocalPlayer.TagEquipped.Value ~= Tag or isInGroup == true or game.Players.LocalPlayer.TagEquipped.Value ~= Tag or isInBadge == true and game.Players.LocalPlayer.TagEquipped.Value ~= Tag then
Info.UntukGrup.Image = ""
Info.UntukGrup.Visible = false
Info.Bdgs12.Visible = false
Info.Buy.Text = "Equip"
Info.Buy.Roundify.ImageColor3 = Color3.fromRGB(85, 170, 255)
end
if game.Players.LocalPlayer.TagEquipped.Value == Tag then
Info.UntukGrup.Visible = false
Info.UntukGrup.Image = ""
Info.Buy.Text = "Equipped"
Info.Buy.Roundify.ImageColor3 = Color3.fromRGB(255, 96, 99)
end
if game.Players.LocalPlayer.Tags[Tag].Value == false and isInGroup == nil and isInBadge == nil then
Info.UntukGrup.Visible = false
Info.UntukGrup.Image = ""
Info.Buy.Text = "Buy"
Info.Buy.Roundify.ImageColor3 = Color3.fromRGB(85, 255, 0)
end
if isInGroup == false then
Info.Buy.Text = "Join"
Info.UntukGrup.Visible = true
Info.Buy.Roundify.ImageColor3 = Color3.fromRGB(186, 186, 186)
end
if isInBadge == false then
Info.Buy.Text = "Get"
Info.Buy.Roundify.ImageColor3 = Color3.fromRGB(255, 255, 0)
end
end
end
Script Buy/Equip
local function equip(player,tag)
local AlatMainan = player.Backpack
for i,v in pairs(AlatMainan:GetChildren()) do
if v:IsA("Tool") then
v:Destroy()
end
end
local GGMainanAlat = game.ReplicatedStorage.AlatMain:WaitForChild(tag).Tag:Clone()
GGMainanAlat.NamaAlat.Value = tag
GGMainanAlat.Parent = AlatMainan
player.TagEquipped.Value = tag
end
script.Parent.BuyEvent.OnServerEvent:Connect(function(player,tag,group,BadgeV)
local Tag = game.ReplicatedStorage.AlatMain[tag]
local Currency = player.leaderstats[game.ReplicatedStorage.AlatMain.Currency.Value]
local Price = Tag.Price
if Currency.Value >= Price.Value and player.Tags:FindFirstChild(tag) and player.Tags[tag].Value == false and not Tag.Price:FindFirstChild("ID") and not Tag.Price:FindFirstChild("Group") and not Tag.Price:FindFirstChild("BadgeV") then
Currency.Value = Currency.Value - Price.Value
player.Tags[tag].Value = true
elseif player.Tags:FindFirstChild(tag) and player.Tags[tag].Value == true then
equip(player,tag)
elseif player.Tags:FindFirstChild(tag) and Tag.Price:FindFirstChild("Group") and group == true then
equip(player,tag)
elseif player.Tags:FindFirstChild(tag) and Tag.Price:FindFirstChild("BadgeV") and BadgeV == true then
equip(player,tag)
end
end)
localScript Click
local MPS = game:GetService("MarketplaceService")
local sd = script.Parent.Apanih["Button Click Release"]
local groupinfo = game:GetService("BadgeService")
script.Parent.A.Info.Frame.Buy.MouseButton1Down:Connect(function()
sd:Play()
local Tag = script.Parent.A.Info.Frame.NamaAlat.Text
if game.ReplicatedStorage.AlatMain:FindFirstChild(Tag) then
local Player = game.Players.LocalPlayer
local Currency = Player.leaderstats[game.ReplicatedStorage.AlatMain.Currency.Value]
local Price = game.ReplicatedStorage.AlatMain[Tag].Price
local isInGroup = nil
local isInBadge = nil
if Price:FindFirstChild("ID") and Player.Tags[Tag].Value == false then
MPS:PromptGamePassPurchase(Player,Price.ID.Value)
end
if Price:FindFirstChild("Group") then
isInGroup = Player:IsInGroup(Price.Group.Value)
end
if Price:FindFirstChild("BadgeV") then
isInBadge = groupinfo:UserHasBadgeAsync(Player.UserId,Price.BadgeV.Value)
end
script.Parent.BuyEvent:FireServer(Tag,isInGroup,isInBadge)
end
end)
localScript Info
local deb = false
local sd = script.Parent.Apanih["Switch 2 (SFX)"]
while true do
wait(0.1)
for i,v in pairs(script.Parent.A.TagsFrame:GetChildren()) do
if v:IsA("ImageLabel") then
v.Click.MouseButton1Down:Connect(function()
sd:Play()
if deb == false then
deb = true
local Info = script.Parent.A.Info.Frame
local Tag = game.ReplicatedStorage.AlatMain:FindFirstChild(v.Name)
local IDBdg = game.ReplicatedStorage.AlatMain:FindFirstChild(v.Name)
if Tag then
Info.Visible = true
Info.NamaAlat.Text = v.Name
Info.FotoAlat.Image = game.ReplicatedStorage.AlatMain[v.Name].Tag.TextureId
if Tag.Price:FindFirstChild("ID") then
local MPS = game:GetService("MarketplaceService")
local PassInfo = MPS:GetProductInfo(Tag.Price.ID.Value,Enum.InfoType.GamePass)
local Price = PassInfo.PriceInRobux
if Price then
Info.HaragAlat.Text = Price.." Robux"
end
elseif Tag.Price:FindFirstChild("Group") then
local groupinfo = game:GetService("GroupService"):GetGroupInfoAsync(Tag.Price.Group.Value)
if groupinfo and groupinfo.Name then
Info.HaragAlat.Text = "Join "..groupinfo.Name.." Roblox Group"
end
elseif Tag.Price:FindFirstChild("BadgeV") then
local BS = game:GetService("BadgeService")
local isBadge = BS:GetBadgeInfoAsync(IDBdg.Price.BadgeV.Value)
if isBadge and isBadge.Name then
Info.HaragAlat.Text = "Get "..isBadge.Name.." Badge"
Info.Bdgs12.Image = "rbxassetid://" ..isBadge.IconImageId
end
else
Info.HaragAlat.Text = "Rp "..Tag.Price.Value
end
end
wait(0.3)
deb = false
end
end)
end
end
end