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

Why does the Motor6D only shows on the Client Side and not also Server Side?

Asked by 3 years ago
Edited 3 years ago

So it's a drill tool so when you press a key it switches stances, it works fine, animations are good, no errors. But the position of the gun, it only shows on the Client and not also the Server, does anyone know why?

Video Example: https://streamable.com/kz5vkc

This is what is inside the tool: https://media.discordapp.net/attachments/462676564815904768/840644481279197244/unknown.png

Code (in a regular script)

local Tool = script.Parent
local player = script.Parent.Parent.Parent
local char = game.Workspace:WaitForChild(player.Name)
local Humanoid = char.Humanoid
local OrderArms=Humanoid:LoadAnimation(script.Parent.OrderArms)
local OrderToShoulder=Humanoid:LoadAnimation(script.Parent.OrderToShoulder)
local ShoulderArms=Humanoid:LoadAnimation(script.Parent.ShoulderArms)
local ShoulderToPresent=Humanoid:LoadAnimation(script.Parent.ShoulderToPresent)
local PresentArms=Humanoid:LoadAnimation(script.Parent.PresentArms)
local PresentToShoulder=Humanoid:LoadAnimation(script.Parent.PresentToShoulder)
local ShoulderToOrder=Humanoid:LoadAnimation(script.Parent.ShoulderToOrder)
local Salute=Humanoid:LoadAnimation(script.Parent.Salute)

Tool.Equipped:connect(function(mouse)
    wait()
    local motorr = Instance.new("Motor6D",script.Parent.Parent["Right Arm"])
    motorr.Name="HandleMotor6D"
    motorr.Part0=script.Parent.Parent["Right Arm"]
    motorr.Part1=script.Parent.Handle
    motorr.Parent.RightGrip:Destroy()
    wait()
    OrderArms:Play()
    script.Parent.Stance.Value = "Order"
    bounce = false
end)

Tool.Unequipped:Connect(function()
    char["Right Arm"]:WaitForChild("HandleMotor6D"):Destroy()
end)

script.Parent.DrillEvent.OnServerEvent:connect(function(player,movement)
    if movement=="OrderToShoulder" then
            script.Parent.Stance.Value = "Transitioning"
            bounce = true
            OrderToShoulder:Play()
            OrderArms:Stop(3)
            wait(1.6)
            ShoulderArms:Play()
            OrderToShoulder:Stop(3)
            script.Parent.Stance.Value = "Shoulder"
    elseif movement=="ShoulderToPresent" then
            script.Parent.Stance.Value = "Transitioning"
            Humanoid.WalkSpeed=0
            ShoulderToPresent:Play()
            ShoulderArms:Stop(3)
            wait(2)
            PresentArms:Play()
            ShoulderToPresent:Stop(3.75)
            script.Parent.Stance.Value = "Present" 
    elseif movement=="PresentToShoulder" then
            script.Parent.Stance.Value = "Transitioning"
            PresentToShoulder:Play()
            PresentArms:Stop(2)
            wait(1.3)
            ShoulderArms:Play()
            PresentToShoulder:Stop(5)
            script.Parent.Stance.Value = "Shoulder" 
            Humanoid.WalkSpeed=16
    elseif movement=="ShoulderToOrder" then
            script.Parent.Stance.Value = "Transitioning"
            ShoulderToOrder:Play()
            ShoulderArms:Stop(2)
            wait(2.5)
            OrderArms:Play()
            ShoulderToOrder:Stop(5)
            script.Parent.Stance.Value = "Order" 
    elseif movement=="SaluteUp" then
            script.Parent.Stance.Value = "Saluting"
            Salute:Play()
            wait(0.5)
            Salute:AdjustSpeed(0)
            script.Parent.Stance.Value = "SaluteUp" 
    elseif movement=="SaluteDown" then
            script.Parent.Stance.Value = "Saluting"
            Salute:AdjustSpeed(1)
            wait(0.5)
            Salute:Stop()
            script.Parent.Stance.Value = "Shoulder" 
    elseif movement=="AllStop" then
        OrderArms:Stop()
        OrderToShoulder:Stop()
        ShoulderArms:Stop()
        PresentArms:Stop()
        PresentToShoulder:Stop()
        ShoulderToPresent:Stop()
        ShoulderToOrder:Stop()
        Salute:Stop()
    end
end)

Code: (Local Script)

local Tool = script.Parent

Tool.Equipped:connect(function(mouse)
local function onKeyPress(actionName, userInputState, inputObject)
        if userInputState == Enum.UserInputState.Begin and script.Parent.Stance.Value == "Order" then
            script.Parent.DrillEvent:FireServer("OrderToShoulder")
        elseif userInputState == Enum.UserInputState.Begin and script.Parent.Stance.Value == "Present" then
            script.Parent.DrillEvent:FireServer("PresentToShoulder")
        end
    end
local function onKeyPress2(actionName, userInputState, inputObject)
        if userInputState == Enum.UserInputState.Begin and script.Parent.Stance.Value == "Shoulder" then
            script.Parent.DrillEvent:FireServer("ShoulderToPresent")
        elseif userInputState == Enum.UserInputState.Begin and script.Parent.Stance.Value == "Present" then
            script.Parent.DrillEvent:FireServer("PresentToShoulder")
        end 
    end
local function onKeyPress3(actionName, userInputState, inputObject)
        if userInputState == Enum.UserInputState.Begin and script.Parent.Stance.Value == "Shoulder" then
            script.Parent.DrillEvent:FireServer("ShoulderToOrder")
        end 
    end
local function onKeyPress4(actionName, userInputState, inputObject)
        if userInputState == Enum.UserInputState.Begin and script.Parent.Stance.Value == "Shoulder" then
            script.Parent.DrillEvent:FireServer("SaluteUp")
        elseif userInputState == Enum.UserInputState.Begin and script.Parent.Stance.Value == "SaluteUp" then
            script.Parent.DrillEvent:FireServer("SaluteDown")
        end 
    end
    Tool.Unequipped:connect(function(mouse)
        script.Parent.DrillEvent:FireServer("AllStop")
    end) 
    game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.Y)
    game.ContextActionService:BindAction("keyPress2", onKeyPress2, false, Enum.KeyCode.H)
    game.ContextActionService:BindAction("keyPress3", onKeyPress3, false, Enum.KeyCode.T)
    game.ContextActionService:BindAction("keyPress4", onKeyPress4, false, Enum.KeyCode.G)
end)

Tool.Unequipped:connect(function()
    script.Parent.Stance.Value = "Unequipped"
end)

Answer this question