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

why doesn't the animation play if I equip my cloned tool but works fine in my primary one ?

Asked by 3 years ago

usually , an animation will play if the tool is equipped , here is the code for the tool :

local tool = script.Parent

local cooldownindic = true
local active = nil

tool.Equipped:Connect(function(test)

    player = tool.Parent
    if tool.Parent:FindFirstChildWhichIsA("Humanoid") then
        print("yes")
        player = tool.Parent
        print("Owner is " .. player.Name)
        print(tool.Parent.Name)
        game.Workspace.STOPMOVE:FireClient(game.Players[tostring(player)])
        wait(0.1)
        tool.Parent.Humanoid.Jump = true
        local animation = Instance.new("Animation")
        animation.AnimationId = "http://www.roblox.com/asset/?id=5247534289" 
        local animationTrack = tool.Parent.Humanoid:LoadAnimation(animation)
        animationTrack:Play()

        local Animation = game.Workspace[tostring(player.Name)].Animate
        Animation.idle.Animation1.AnimationId = "rbxassetid://5242207020"
        Animation.idle.Animation2.AnimationId = "rbxassetid://5242207020"
        Animation.run.RunAnim.AnimationId = "rbxassetid://5246789637"
        Animation.walk.WalkAnim.AnimationId = "rbxassetid://5246789637"
        player.Humanoid.WalkSpeed = "8"

        tool.Unequipped:Connect(function()
            game.Workspace.STOPMOVE:FireClient(game.Players[tostring(player)])
            player.Humanoid.Jump = true
            local Animation = game.Workspace[tostring(player.Name)].Animate
            Animation.idle.Animation1.AnimationId = "rbxassetid://2510196951"
            Animation.idle.Animation2.AnimationId = "rbxassetid://2510197257"
            Animation.run.RunAnim.AnimationId = "rbxassetid://2510198475"
            Animation.walk.WalkAnim.AnimationId = "rbxassetid://2510202577"

            player.Humanoid.WalkSpeed = "16"
        end)
    end
end)


local function testdamage()
    script.Parent.Wedge1.Script.Disabled = false
    wait(0.5)
    script.Parent.Wedge1.Script.Disabled = true
end
tool.Activated:Connect(function(plr)


    active = true
    while true do
        if active == true then
            if cooldownindic == true then
                cooldownindic = false
                local animation = Instance.new("Animation")
                animation.AnimationId = "http://www.roblox.com/asset/?id=5257864837" 
                local animationTrack = tool.Parent.Humanoid:LoadAnimation(animation)
                animationTrack:Play()
                wait(0.57)
                testdamage()
                wait(0.5)
                cooldownindic = true
            end
        end
        wait(0.01)
    end
end)    
tool.Deactivated:Connect(function(plr)
      active = false
end)

it works just fine , but if i clone the tool , even if the script is cloned , its like there is no script in my SECOND tool , the first tool still works fine

my clone code :

local Common = game.ReplicatedStorage.Tool:Clone()
Common.Parent = game.Workspace[tostring(game.Players.LocalPlayer)]

and i tried to clone it to my backpack too :

game.ReplicatedStorage.Tool:Clone().Parent = game.Players.LocalPlayer.Backpack

still nothing is happening

how do I fix this ?

1 answer

Log in to vote
0
Answered by
bluzorro 417 Moderation Voter
3 years ago

From what I've seen, the only problem would be at the cloning.

game.Workspace[tostring(game.Players.LocalPlayer)] is the problem. You can't use tostring on an object, it would return nil. So you need to get the .Name of the LocalPlayer, without the tostring() function.

0
ok ill try doing what you said rupertrosse 39 — 3y
0
its still the same outcome , its not the answer im looking for but thanks anyway rupertrosse 39 — 3y
Ad

Answer this question