So I just started doing Viewmodel...And my animations wont play. Idk why. Theres no errors/ouput.
Heres my gun script. The gun model in inside the players camera.
local Player = game.Players.LocalPlayer
local Character = Player.Character
wait(1)
local Gun = workspace.Camera["Val ViewModel"]
local Reloading = false
local Idle = Gun.Humanoid:LoadAnimation(Gun.Idle)
local Reload = Gun.Humanoid:LoadAnimation(Gun.Reload)
local Shoot = Gun.Humanoid:LoadAnimation(Gun.Shoot)
local Sprint = Gun.Humanoid:LoadAnimation(Gun.Sprint)
Idle:Play()
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 and Reloading == false and Gun.AmmoFolder.Ammo.Value >= 1 then
print("Fired Gun")
Gun.AmmoFolder.Ammo.Value = Gun.AmmoFolder.Ammo.Value - 1
Shoot:Play()
Gun.Fire:Play()
Gun.Fire2:Play()
local ray = Ray.new(Gun.Val.Flash.Position, (Player:GetMouse().Hit.p - Gun.Val.Flash.Position).unit * 300)
local Part, Position = workspace:FindPartOnRay(ray, Character, false, true)
local Beam = Instance.new("Part", workspace)
Beam.BrickColor = BrickColor.new("Bright red")
Beam.FormFactor = "Custom"
Beam.Material = "Neon"
Beam.Transparency = 0.5
Beam.Anchored = true
Beam.Locked = true
Beam.CanCollide = false
local distance = (Gun.Val.Flash.Position - Position).magnitude
Beam.Size = Vector3.new(0.3, 0.3, distance)
Beam.CFrame = CFrame.new(Gun.Val.Flash.Position, Position) * CFrame.new(0, 0, -distance / 2)
game:GetService("Debris"):AddItem(Beam, 0.1)
end
if input.KeyCode == Enum.KeyCode.R and Reloading == false then
Reloading = true
print("Reloading")
Gun.AmmoFolder.ReserveAmmo.Value = Gun.AmmoFolder.ReserveAmmo.Value - Gun.AmmoFolder.AmmoPerMag.Value
Reload:Play()
Gun.Mag:Play()
wait(2)
Gun.AmmoFolder.Ammo.Value = Gun.AmmoFolder.AmmoPerMag.Value
Reloading = false
end
end)

3 comments
The parent argument to Instance.new is deprecated, assign the parent in another line as the last property. FormFactor is also deprecated
Ok, update....They work in online mode but not studio
That's a good thing. As long as it works in game you're ok.