-
What do you want to achieve? An answer, solution, result, anything to work or find error to the movement of my tank.
-
What is the issue? For some reason–despite the working function of the “UpArrow” and “DownArrow” parts of the code (respectively to the keyboard)–the “LeftArrow” and “RightArrow” parts of the code don’t work (again, respective to the keyboard) with no errors showing up the output relating to the global script or local script using UserInputService (located in StarterPlayerScripts) in action. Strangely, other events in the same local script, including the up and down arrow parts of the global script, function.
I have taken notice that the Hinge Constraint’s rotation works when changing it manually, where as an example: if I left the AngularVelocity as 0.3 before running an instance on Roblox Studio, it functions properly both in client and server. Another example of this is changing it on an active instance, where that functions with no issues, client or server.
AngularVelocity Not Changed
AngularVelocity Changed
I have also taken notice that the up and down arrow parts do visually change (as in being seen in the properties) the AngularVelocity but the the left and right arrow parts do not visually change the AngularVelocity (as in being seen in the properties).
- What solutions have you tried so far? I have looked online with multiple variations of searches, but I do not think any of them have hit the correct question I need to be asking. I have looked throughout the Devforum but I cannot the answers needed. I have looked on YouTube and haven’t found the proper solution. I even tried some testing with printing and copy and pasted working code (of course with modifications to make it applicable). Maybe I’m not looking as in-depth, but I have nothing to start off with.
(Full scripts below)
local ArrowUpEvent = game:GetService("ReplicatedStorage"):WaitForChild("ArrowUpEvent")
local ArrowDownEvent = game:GetService("ReplicatedStorage"):WaitForChild("ArrowDownEvent")
local ArrowLeftEvent = game:GetService("ReplicatedStorage"):WaitForChild("ArrowLeftEvent")
local ArrowRightEvent = game:GetService("ReplicatedStorage"):WaitForChild("ArrowRightEvent")
ArrowDownEvent.OnServerEvent:Connect(function(plr, truf)
if truf == true then
script.Parent.Turret.HingeConstraint.AngularVelocity = -0.3
script.Parent.TurretBase.TurretStart:Play()
script.Parent.TurretBase.TurretLoop:Play()
elseif truf == false then
script.Parent.Turret.HingeConstraint.AngularVelocity = 0
script.Parent.TurretBase.TurretLoop:Stop()
script.Parent.TurretBase.TurretStop:Play()
end
end)
ArrowUpEvent.OnServerEvent:Connect(function(plr, truf)
if truf == true then
script.Parent.Turret.HingeConstraint.AngularVelocity = 0.3
script.Parent.TurretBase.TurretStart:Play()
script.Parent.TurretBase.TurretLoop:Play()
elseif truf == false then
script.Parent.Turret.HingeConstraint.AngularVelocity = 0
script.Parent.TurretBase.TurretLoop:Stop()
script.Parent.TurretBase.TurretStop:Play()
end
end)
ArrowLeftEvent.OnServerEvent:Connect(function(plr, truf)
if truf == true then
script.Parent.Hull.HingeConstraint.AngularVelocity = 0.3
script.Parent.TurretBase.TurretStart:Play()
script.Parent.TurretBase.TurretLoop:Play()
elseif truf == false then
script.Parent.Hull.HingeConstraint.AngularVelocity = 0
script.Parent.TurretBase.TurretLoop:Stop()
script.Parent.TurretBase.TurretStop:Play()
end
end)
ArrowRightEvent.OnServerEvent:Connect(function(plr, truf)
if truf == true then
script.Parent.Hull.HingeConstraint.AngularVelocity = -0.3
script.Parent.TurretBase.TurretStart:Play()
script.Parent.TurretBase.TurretLoop:Play()
elseif truf == false then
script.Parent.Hull.HingeConstraint.AngularVelocity = 0
script.Parent.TurretBase.TurretLoop:Stop()
script.Parent.TurretBase.TurretStop:Play()
end
end)
uis.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Up and not processed then
game:GetService("ReplicatedStorage").ArrowUpEvent:FireServer(true)
end
end)
uis.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Down and not processed then
game:GetService("ReplicatedStorage").ArrowDownEvent:FireServer(true)
end
end)
uis.InputEnded:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Up and not processed then
game:GetService("ReplicatedStorage").ArrowUpEvent:FireServer(false)
end
end)
uis.InputEnded:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Down and not processed then
game:GetService("ReplicatedStorage").ArrowDownEvent:FireServer(false)
end
end)
uis.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Left and not processed then
game:GetService("ReplicatedStorage").ArrowLeftEvent:FireServer(true)
end
end)
uis.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Right and not processed then
game:GetService("ReplicatedStorage").ArrowRightEvent:FireServer(true)
end
end)
uis.InputEnded:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Left and not processed then
game:GetService("ReplicatedStorage").ArrowLeftEvent:FireServer(false)
end
end)
uis.InputEnded:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Right and not processed then
game:GetService("ReplicatedStorage").ArrowRightEvent:FireServer(false)
end
end)