I am completelty new to roblox studio and are helping a friend handle a game, but I don't know what I've done wrong with this script.
I used Rustysillybands' tutorial on animating guns but I can't seem to be able to get it working.
https://www.youtube.com/watch?v=1tRlSd49qmw&t=182s
Code here:
LocalScript in tool:
--Service--
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
--Variables--
local player = Players.LocalPlayer
local tool = script.Parent
local animations = script.Parent.Animations
--Functions--
UserInputService.InputBegan:Connect(function(input: Enum.KeyCode, gameProcessedEvent)
if gameProcessedEvent then return end
if input.Keycode == Enum.Keycode.R then
if player.Character:FindFirstChild(tool.Name) then
local animationTrack = player.Character:FindFirstChild("Humanoid").Animator:LoadAnimation(animations.Reload)
animationTrack:Play()
end
end
end)
local idleAnimationTrack = player.Character:FindFirstChild("Humanoid").Animator:LoadAnimation(animations.Idle)
tool.Equipped:Connect(function()
idleAnimationTrack:Play()
end)
tool.Unequipped:Connect(function()
idleAnimationTrack:Stop()
end)
Script in ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
task.wait(1)
local motor6d = Instance.new("Motor6D")
motor6d.Name = "ToolAttach"
motor6d.Parent = character.RightHand
character.ChildAdded:Connect(function(child)
if child:IsA("Tool") and child:FindFirstChild("Body") then
motor6d.Part1 = child.Body
end
end)
end)
end)
How to ANIMATE GUNS In Roblox Studio!
🛠 This is How to ANIMATE GUNS In Roblox Studio! Thanks so much for watching, hope you guys have a great day! Subscribe 😎🛠
Constraint Editor Plugin: https://create.roblox.com/store/asset/804263305/Constraint-Editor?externalSource=www
Tool Part Animation Tutorial by Headstackk: https://devforum.rob...