Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script doesn't unequip Auras? (ANSWER PLEASE) (contains another question)

Asked by 4 years ago
Edited 4 years ago

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)
0
its because your toggles are wrong. or debounce. why is your mouse button1down function ending like instantly? your function ends and there is nothing inside of it. no code at all.  legoguy939 418 — 4y
0
talk to me in sh chat legoguy939 418 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
Ad

Answer this question