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

ok so how can i make my sword not hit and give strenght while the animation is playing?

Asked by
seikkatsu 110
4 years ago
------------------< variables >----------------
local uis = game:GetService("UserInputService")
local saber = script.Parent
local p = game.Players.LocalPlayer
local l = p.leaderstats
local equipped = false
local textBox = game.StarterGui.Strenght.TextLabel
local anim = script.Parent:WaitForChild("SwingAnimation")
------------------< code >---------------------
saber.Equipped:Connect(function()
    equipped = true
end)
saber.Unequipped:Connect(function()
    equipped = false
end)
uis.InputBegan:Connect(function(input1)
    local mouseIn1 = input1.UserInputType
    if equipped == true and mouseIn1 == Enum.UserInputType.MouseButton1 then
        wait(0.6)
        l.Strenght.Value = l.Strenght.Value + 5
        local loadedAnim = p.Character.Humanoid:LoadAnimation(anim)
        loadedAnim:Play()
    end
end)

this is my script it works totally fine, but i want to know how to make the sword not give any strenght while the animation is playing any help is apriciated

0
Could use an if statement to not run any damage code when the animation is playing. Think you could use this https://developer.roblox.com/en-us/api-reference/property/AnimationTrack/IsPlaying ForeverBrown 356 — 4y
0
ok so i did this "if anim.IsPlaying == true and mouseIn1 == Enum.UserInputType.MouseButton1 then wait(0.6) end" and it gives me an error seikkatsu 110 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Try to switch like that

            local loadedAnim = p.Character.Humanoid:LoadAnimation(anim)
            loadedAnim:Play()
        wait(2)
l.Strenght.Value = l.Strenght.Value + 5

edit:

local uis = game:GetService("UserInputService")
    local saber = script.Parent
    local p = game.Players.LocalPlayer
    local l = p.leaderstats
    local equipped = false
    local textBox = game.StarterGui.Strenght.TextLabel
    local anim = script.Parent:WaitForChild("SwingAnimation")
    local hitt = 1
    ------------------< code >---------------------
    saber.Equipped:Connect(function()
        equipped = true
    end)
    saber.Unequipped:Connect(function()
        equipped = false
    end)
    uis.InputBegan:Connect(function(input1)
        local mouseIn1 = input1.UserInputType
        if equipped == true and mouseIn1 == Enum.UserInputType.MouseButton1 then
            if hitt == 1 then
                l.Strenght.Value = l.Strenght.Value + 5
                local loadedAnim = p.Character.Humanoid:LoadAnimation(anim)
                loadedAnim:Play()
                hitt = 0
                wait(1)
                hitt = 1
            end
        end
    end)
0
one second seikkatsu 110 — 4y
0
ok so the player can still hit while the animation is playing. this is my problem. ill give you a link of a video of my problem seikkatsu 110 — 4y
0
sorry for the bad quality but i'm sure you can understand what's going on https://imgur.com/a/fLocq5Y seikkatsu 110 — 4y
0
got it, i think i fixed it, i'll put the script in a new comment HaosKiid 22 — 4y
View all comments (5 more)
0
nvm, i edited this comment, let me know if is working HaosKiid 22 — 4y
0
if you don't get any errors and you can still hit while is animating, switch the wait time from "if hitt == 1 then"... HaosKiid 22 — 4y
0
what is the "hitt " variable supposed to mean? the time of the animation or what? i don't really get it seikkatsu 110 — 4y
0
is like ammo, you need to wait until you reload to shoot again HaosKiid 22 — 4y
0
thanks a lot seikkatsu 110 — 4y
Ad

Answer this question