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

My animation doesn't work in game but it works in studio why does this happen and can you help?

Asked by 7 years ago
Edited 7 years ago

I put this code in a script because I'm animating a r15 viewmodel for my fps and it works in studio but not in game. This code is in a normal script too. sorry I have to drag out the title but anyway here is the script.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local uis = game:GetService("UserInputService")
local reloading = false
local sprinting = false

local controller = Instance.new("AnimationController")
controller.Parent = script.Parent
local idle = controller:LoadAnimation(script.Parent.Idle)
local shoot = controller:LoadAnimation(script.Parent.Shoot)
local reload = controller:LoadAnimation(script.Parent.Reload)
local sprint = controller:LoadAnimation(script.Parent.Sprint)

idle.Looped = true
shoot.Looped = false
reload.Looped = false
sprint.Looped = true

idle:Play()

shootsound = script.Parent.Fire2:Clone()

mouse.Button1Down:connect(function()
if reloading == false then

local shootsound = script.Parent.Fire2:Clone()
shootsound.Parent = script.Parent
shootsound.MaxDistance = 500
shootsound.Volume = 0.3

shoot:Play()
script.Parent.M1911.Flash.SparkFX.Enabled = true
script.Parent.M1911.Flash.Flash.Enabled = true
shootsound.Playing = true
wait(.5)

script.Parent.M1911.Flash.SparkFX.Enabled = false
script.Parent.M1911.Flash.Flash.Enabled = false

game.Debris:AddItem(shootsound,3)
idle:Play()
end
end)

uis.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.R then
if reloading == false then
reloading = true

idle:Stop()
reload:Play()
script.Parent.Mag:Play()

wait(1.5)
reloading = false
idle:Play()
        end
    end
end)

uis.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if reloading == false then
idle.Looped = false

sprint:Play()
sprint.Looped = true
player.Character.Humanoid.WalkSpeed = 24

        end
    end
end)

uis.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if reloading == false then

sprint.Looped = false
idle:Play()
idle.Looped = true
player.Character.Humanoid.WalkSpeed = 16
        end
    end
end)

this is a long script but I don't know why it won't work in game please help.

0
Tab your code Goulstem 8144 — 7y
0
how does that help? @Goulstem GameBoyOtaku 63 — 7y
1
Organized and easier to read, makes helping a lot easier. Kareem35 79 — 7y
0
so you want be to repost this but easier to read correct? GameBoyOtaku 63 — 7y
View all comments (3 more)
0
I noticed you said you put it in a script. Is this a normal or localscript? Nikkulaos 229 — 7y
0
This is in a normal script GameBoyOtaku 63 — 7y
0
You can edit a post, y'know. hiimgoodpack 2009 — 7y

Answer this question