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

So, I've tried countless times to get this to work, any idea whats wrong?

Asked by 5 years ago
Edited 5 years ago

From what I understand, I'm doing something wrong with the animation.

local player = game.Players.LocalPlayer
local blast = game.ReplicatedStorage.Blast
local mouse = player:GetMouse()
local clone = game.ReplicatedStorage.Blast:Clone()
local humanoid = player.Character.Humanoid
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=2065147076"

--------------------------------------------------Variables

mouse.KeyDown:connect(function(key)
    if not Enabled then return end
    key = key:lower()
    if key == "q" then 
    local playAnim = humanoid.LoadAnimation(anim)
    playAnim:Play()
    local f = blast
    blast.Parent = workspace
    local BodyVelocity = Instance.new("BodyVelocity", blast)
    BodyVelocity.maxForce = Vector3.new(math.huge,math.huge,math.huge)
    BodyVelocity.Velocity = Character.HumanoidRootPart.CFrame.lookVector *120   
    game.Debris:AddItem(q, 2)
end
  Mouse.KeyUp:connect(function(key)
    key = key:lower()
    if key == "q" then    
    end
end
0
line 15 change the '.' to ':' User#20388 0 — 5y
0
You should be using UIS or CAS to handle user input. T0XN 276 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

On line 15, it should be ':' instead of '.', or humanoid:LoadAnimation() instead of humanoid.LoadAnimation. If you look at the roblox wiki, you can use the example code as a hint.

Here is the new code:

local player = game.Players.LocalPlayer
local blast = game.ReplicatedStorage.Blast
local mouse = player:GetMouse()
local clone = game.ReplicatedStorage.Blast:Clone()
local humanoid = player.Character.Humanoid
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=2065147076"

--------------------------------------------------Variables

mouse.KeyDown:connect(function(key)
    if not Enabled then return end
    key = key:lower()
    if key == "q" then 
    local playAnim = humanoid:LoadAnimation(anim)
    playAnim:Play()
    local f = blast
    blast.Parent = workspace
    local BodyVelocity = Instance.new("BodyVelocity", blast)
    BodyVelocity.maxForce = Vector3.new(math.huge,math.huge,math.huge)
    BodyVelocity.Velocity = Character.HumanoidRootPart.CFrame.lookVector *120   
    game.Debris:AddItem(q, 2)
end
  Mouse.KeyUp:connect(function(key)
    key = key:lower()
    if key == "q" then    
    end
end
Ad

Answer this question