I am new at coding in lua and using roblox studio but anyways I wanna make a animated steering wheel and that the player can play animation wiht the hands its (R6) and its in a localscript its client sided… is there anyway to make it function in a localscript and that the player animation and the steering wheel animation is so other people in the game can see it?
The localscript is in the StarterPlayerScripts:
local player = game:GetService("Players").LocalPlayer
local part = game.Workspace[player.Name.."_Jeep"].Wheel.Union
local rotateSpeed = 90
local sAnimationId = "15436527787"
local aAnimationId = "15436548044"
local sAnimTrack = nil
local aAnimTrack = nil
local function playAnimation(animationId)
local animController = part:FindFirstChildOfClass("Humanoid") or part:FindFirstChildOfClass("AnimationController")
if animController then
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://" .. tostring(animationId)
local animTrack = animController:LoadAnimation(animation)
animTrack:Play()
return animTrack
end
end
local function stopAnimation(animTrack)
if animTrack then
animTrack:Stop()
animTrack:Destroy()
end
end
local function onKeyPress(input)
if input.KeyCode == Enum.KeyCode.S then
sAnimTrack = playAnimation(sAnimationId)
game.ReplicatedStorage.Turning:FireServer("PlayAnimation", "S")
elseif input.KeyCode == Enum.KeyCode.A then
aAnimTrack = playAnimation(aAnimationId)
game.ReplicatedStorage.Turning:FireServer("PlayAnimation", "A")
end
end
local function onKeyRelease(input)
if input.KeyCode == Enum.KeyCode.S then
stopAnimation(sAnimTrack)
game.ReplicatedStorage.Turning:FireServer("StopAnimation", "S")
elseif input.KeyCode == Enum.KeyCode.A then
stopAnimation(aAnimTrack)
game.ReplicatedStorage.Turning:FireServer("StopAnimation", "A")
end
end
game:GetService("UserInputService").InputBegan:Connect(onKeyPress)
game:GetService("UserInputService").InputEnded:Connect(onKeyRelease)