So i am making a custom character controller (which is a boll) using velocity I want is velocity in Z axis is always adding up and if you press d it goes right (left is remaining)
this are the scripts:
client script:
--Made By Beastcraft_Gaming--
--28/10/20--
--Variables
--Services
local workSpace = game:GetService("Workspace") -- workSpace
local ReplicatedStorage = game:GetService("ReplicatedStorage") --ReplicatedStorage
local RunService = game:GetService("RunService") --RunService
local ContextActionService = game:GetService("ContextActionService"); --ContextActionService
--Instances
local player = workSpace:WaitForChild("player"); --player
local camera = workSpace.CurrentCamera; --camera
local PushRemote = ReplicatedStorage:WaitForChild("PlayerRemotes"):WaitForChild("Push"); --PushRemote
local LeftRemote = ReplicatedStorage:WaitForChild("PlayerRemotes"):WaitForChild("Left"); --LeftRemote
--Values
local offSet = Vector3.new(0,4,10);
--Miscelenious
local LeftAction = "Left"
--Properties
camera.CameraType = Enum.CameraType.Scriptable; --so script can change it
--functions
local function OnRenderStep()
local newOffSet = offSet + player.Position;
camera.CFrame = CFrame.new(newOffSet);
PushRemote:FireServer(RunService.Heartbeat:Wait())
end
local function OnLeftUserInput(ActionName, InputeState, InputObject)
print('EventFired'); --it prints
if ActionName == "Left" and InputeState == Enum.UserInputState.Begin then
LeftRemote:FireServer(RunService.Heartbeat:Wait())
end
end
--Events
RunService.RenderStepped:Connect(OnRenderStep)
ContextActionService:BindAction(LeftAction, OnLeftUserInput, false, Enum.KeyCode.D);
print(camera.CFrame.Position); --prints the position
print(player.CFrame.Position); --prints the position
Server script:
--Made By Beastcraft_Gaming--
--28/10/20--
--Variables
--Services
local workSpace = game:GetService("Workspace"); --WorkSpace
local ReplicatedStorage = game:GetService("ReplicatedStorage"); --ReplicatedStorage
local RunService = game:GetService("RunService"); --RunService
--Instances
local player = workSpace:WaitForChild("player"); --player
local PushRemote = ReplicatedStorage:WaitForChild("PlayerRemotes"):WaitForChild("Push"); --PushRemote
local LeftPushRemote = ReplicatedStorage:WaitForChild("PlayerRemotes"):WaitForChild("Left"); --LeftRemote
--functions
local function push(deltaTime)
player.Velocity = Vector3.new(0,0,-50)
wait(deltaTime)
end
local function LeftPush(deltaTime)
print("This fired"); --it prints
player.Velocity = player.Velocity + Vector3.new(100,0,0); --it is set so high so I can see the change
wait(deltaTime)
end
--events
PushRemote.OnServerEvent:Connect(function(deltaTime)
push(deltaTime)
end)
LeftPushRemote.OnServerEvent:Connect(function(deltaTime)
LeftPush(deltaTime);
end)
so the problem is the velocity on Z works fine but velocity on X axis doesnt work…