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

How do I make the animation work?

Asked by 8 years ago

I bought the model from PlaceRebuilder for the snow ball fight, but the animation didn't work since it mentioned it in the DESC of his model. So, I made my own, but it didn't do it correctly. When I want to make a snowball, instead of picking it up from the snow on the bottom, it makes the play go up a little and gets the snow ball, and for tossing it, it doesn't do the animation for that either. This is the script and my animation ULR and the model PlaceRebuilder made:

wait(1)

enabled = true
Tool = script.Parent
handle = Tool:WaitForChild("Handle")
local player = game.Players.LocalPlayer

local maxammo = 4
local ammo = 0

local screen = Instance.new("ScreenGui",player.PlayerGui)
local gui = script.Parent:WaitForChild("SnowballAmmo")
gui.Parent = screen


local humanoid = player.Character:WaitForChild("Humanoid")
local toss = script.Parent:WaitForChild("Toss");
local tossAnm = humanoid:LoadAnimation(toss);
local make = script.Parent:WaitForChild("Make");
local makeAnm = humanoid:LoadAnimation(make);

function updateGui()
    gui.Amount.Value = ammo
    if (gui.Amount.Value < 1) then
        script.Parent.Handle.Transparency = 1
    else
        script.Parent.Handle.Transparency = 0
    end
end
updateGui()
Tool = script.Parent
local MAXDISTANCE = 43;

function fire(mouse_pos)

    -- find player's head pos

    local vCharacter = Tool.Parent
    local vPlayer = game.Players:playerFromCharacter(vCharacter)

    local head = vCharacter:findFirstChild("Head")
    if head == nil then return end

    local launch = head.Position + head.CFrame.lookVector*2
    local delta = (mouse_pos - launch)
    local dir = delta.unit
    local missile = script.Parent.Handle:clone()
    missile.Anchored = false
    missile.Name = "Snowball"
    missile.Transparency = 0
    missile.Killer.Value = game.Players:getPlayerFromCharacter(Tool.Parent)

    missile.Position = launch
    missile.Velocity = dir * 200 + Vector3.new(0,20,0)
    missile.PelletScript.Disabled = false
    missile.CanCollide = true

    missile.Parent = vCharacter --game.Workspace --.Game.Trash
end

function onButton1Down(mouse)
    if not enabled or script.Parent.Handle.Transparency == 1 then
        return
    end
    local e = ammo
    if (e > 0) then
        enabled = false
        mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
        ammo = e - 1
        updateGui()
        tossAnm:Play();
        script.Parent.Handle.ThrowSound:Play()
        wait(0.25)
        local targetPos = humanoid.TargetPoint
        fire(targetPos)
        wait(.5)
        mouse.Icon = "rbxasset://textures\\GunCursor.png"
        enabled = true
    end
end

function isOnSnow()
    local ray = Ray.new(script.Parent.Parent.Torso.Position,Vector3.new(0,-4,0))
    local hit = game.workspace:FindPartOnRayWithIgnoreList(ray,{script.Parent.Parent})
    if (hit and hit.Name == "Snow") then
        return true
    end
    return false
end

function keyPressed(key)
    key = key:lower()
    if (not enabled) then return end

    if (key == "e") then
        local e = ammo
        if (e < 4 and isOnSnow()) then
            enabled = false
            makeAnm:Play()
            ammo = e + 1
            updateGui()
            for i = 1,8 do
                humanoid.WalkSpeed = 0
                wait(0.1)
            end
            humanoid.WalkSpeed = 16
            enabled = true
        end
    end
end

function onEquippedLocal(mouse)
    player = game.Players.LocalPlayer
    if mouse == nil then
        print("Mouse not found")
        return 
    end
    mouse.Icon = "rbxasset://textures\\GunCursor.png"
    mouse.Button1Down:connect(function() onButton1Down(mouse) end)
    mouse.KeyDown:connect(keyPressed)
end

Tool.Equipped:connect(onEquippedLocal)

Anim and Model:

Toss Animation: http://www.roblox.com/Toss-Anim-item?id=262087197

Make Animation: http://www.roblox.com/Make-Snowball-item?id=262069382

PlaceRebuilder's Model of SBF: http://www.roblox.com/R2D-Snowballs-item?id=219468856

Hope I explained it and gave all the things I need to fix this script :D

1
1st: Don't buy people's scripts, you will need to learn about animation and animation controllers -- http://wiki.roblox.com/index.php?title=Animations dragonkeeper467 453 — 8y
0
Okay. RobotChitti 167 — 8y

Answer this question