Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

3 comments

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. 

0

talk to me in sh chat

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.