NOTE: I'm posting this question multiple times yet no one answers it. ANSWER IT NOW.
So I'm making a game with a shop that you can buy Auras, This script gives you the aura when you buy it, but it doesn't let you unequip an Aura. Someone help me?
Also does this script buys the thing multiple times even though it is supposed to buy it a single time and let you equip and unequip, if true then help me. Here's the local script:
local player = game.Players.LocalPlayer or game.Players.Players.PlayerAdded:wait() local char = player.character or player.Character or player.CharacterAdded:Wait() local auraEventBlue = game.ReplicatedStorage.AuraEventBlue local variable = false local PurchaseMeter = true script.Parent.MouseButton1Down:Connect(function() for i,v in pairs(game.Players:GetPlayers()) do if v:FindFirstChild("leaderstats") then if v.leaderstats.Credits.Value >= 35 then if PurchaseMeter == true then end v.leaderstats.Credits.Value = v.leaderstats.Credits.Value - 35 PurchaseMeter = false if not variable then variable = true auraEventBlue:FireServer(char) script.Parent.Text = "Disable" else variable = false char.HumanoidRootPart.BlueEffect:Destroy() script.Parent.Text = "Enable" end end end end end)
Here. I have edited this so it should not take credits after you have bought it, and I have rearranged some ends so everything fires correctly.
local player = game.Players.LocalPlayer or game.Players.Players.PlayerAdded:wait() local char = player.character or player.Character or player.CharacterAdded:Wait() local auraEventBlue = game.ReplicatedStorage.AuraEventBlue local variable = false local Purchased = false script.Parent.MouseButton1Down:Connect(function() for i,v in pairs(game.Players:GetPlayers()) do if v:FindFirstChild("leaderstats") then if v.leaderstats.Credits.Value >= 35 then if Purchased == false then v.leaderstats.Credits.Value = v.leaderstats.Credits.Value - 35 Purchased = true end end if not variable then variable = true auraEventBlue:FireServer(char) script.Parent.Text = "Disable" else variable = false char.HumanoidRootPart.BlueEffect:Destroy() script.Parent.Text = "Enable" end end end end)