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

How can I get my tool to play an animation and a sound?

Asked by 3 years ago

I have made a script so when you click it plays a sound and an animation but it doesn't work and I'm not sure whats wrong.

Script: `function onActivated() if not enabled then return end

enabled = false
Tool.GripForward = Vector3.new(0,-.759,-.651)
Tool.GripPos = Vector3.new(1.5,-.5,.3)
Tool.GripRight = Vector3.new(1,0,0)
Tool.GripUp = Vector3.new(0,.651,-.759)


Tool.Handle.DrinkSound:Play()

wait(3)

local h = Tool.Parent:FindFirstChild("Humanoid")
if (h ~= nil) then
    if (h.MaxHealth > h.Health + 5) then
        h.Health = h.Health + 5
    else    
        h.Health = h.MaxHealth
    end
end

Tool.GripForward = Vector3.new(-.976,0,-0.217)
Tool.GripPos = Vector3.new(0.03,0,0)
Tool.GripRight = Vector3.new(.217,0,-.976)
Tool.GripUp = Vector3.new(0,1,0)

enabled = true

end

function onEquipped() Tool.Handle.OpenSound:play() end

script.Parent.Activated:connect(onActivated) script.Parent.Equipped:connect(onEquipped)`

Local Script: script.Parent.Equipped:Connect(function(Mouse) Mouse.Button1Down:Connect(function() animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) animation:Play() end) end)

Answer this question