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

How do I get my drink script to not play if already playing?

Asked by 7 years ago
Edited 7 years ago

I am having trouble getting the script to work as I want it to. Basically, I can spam click and my drink will spam drink. I want it to work so that if you are already drinking, you can't keep clicking to drink while you are already drinking. In other words, I want the onActivated() function to not be able to run if it is already running. I tried using variables, such as:

local DrinkingSound = DrinkSound.Playing
if DrinkSound == true then
script = nil
else return

But, I don't know how to script all that well. My script is below, please assist me ;-;

local Tool = script.Parent;
local GlassBreak = Instance.new("Sound")
GlassBreak.Name = "GlassBreak"
GlassBreak.SoundId = "http://www.roblox.com/asset/?id=11415738"
GlassBreak.Volume = 1
GlassBreak.Parent = Tool
local DrinkSound = Instance.new("Sound")
DrinkSound.Name = "Drink"
DrinkSound.SoundId = "http://www.roblox.com/asset/?id=55609434"
DrinkSound.Volume = 1
DrinkSound.Parent = Tool.Handle
amount = 5
q = Tool.GripForward
w = Tool.GripPos
e = Tool.GripRight
r = Tool.GripUp
function onActivated()
    if not Tool.Enabled  then
        return
    end
DrinkSound:Play()
    wait(1)
    Tool["Water"..amount].Transparency = 1

    local h = Tool.Parent:FindFirstChild("Humanoid")
    if (h ~= nil) then
        h.Health = h.Health + 15
    else
        return
    end
    wait (0.35)
    Tool.GripForward = q
    Tool.GripPos = w
    Tool.GripRight = e
    Tool.GripUp = r
    amount = amount - 1
    if amount == 0 then
        script.Parent:Remove()
    end
    Tool.Enabled = true
end
function onEquipped()
end
script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)
0
UPDATE: I fixed it myself. EliteJcoombs 77 — 7y

Answer this question