I made a sonic gravity controller (using Egomoose’ gravity controller) and wanted to add downwards and upwards momentum, so I made a short script that increases your walk speed depending on the orientation of your character. After I made the script, I play tested my game and my character couldn’t move. I tested this multiple times and became sure that the orientation momentum script is the one breaking the gravity controller. Do you guys have any reasons why?
script:
local HRP = script.Parent.HumanoidRootPart
local orientZ = HRP.Orientation.Z
local orientX = HRP.Orientation.X
script.Parent.Humanoid.Running:Connect(function()
if orientZ == 0 then
script.Parent.Humanoid.WalkSpeed = script.Parent.Humanoid.WalkSpeed + 10000000000
end
end)
The script works whenever I turn off the gravity controller, but this is supposed to slow down/ speed up the player whenever they’re walking on walls with the controller ON. Any reason why this is happening?
for the first question, I added absurd amounts of walkspeed in order to be 100% sure if the script works. For the second question ,the “orientx” isn’t being used in the script YET. I want to make sure a basic version of the script works before I add on to it
try this, not sure if this causes the problem but its definitely isnt supposed to be like that, you are checking the rootparts orientation only once
local HRP = script.Parent.HumanoidRootPart
script.Parent.Humanoid.Running:Connect(function()
local orientZ = HRP.Orientation.Z
local orientX = HRP.Orientation.X
if orientZ == 0 then
script.Parent.Humanoid.WalkSpeed = script.Parent.Humanoid.WalkSpeed + 10000000000
end
end)
heres the thing though, both the scripts I made and you made works perfectly, but only when the gravity controller is turned off. When it’s turned on, it just doesn’t work
So what I did is make a Sign with a TextLabel and the Text of the TextLabel be equal to Orientation Z.
So if Orientation Z is equal to 0, the TextLabel will also be equal to 0.
And I can just make a simple if sentence where if the TextLabel’s text will be equal to 0 the WalkSpeed will be increased.
local HRP = script.Parent.HumanoidRootPart
local Hum = script.Parent.Humanoid
local RunService = game:GetService("RunService")
--the sign
local sign = Instance.new("Part",game.Workspace)
local SurfaceGui = Instance.new("SurfaceGui",sign)
local text = Instance.new("TextLabel")
text.Parent = sign.SurfaceGui
--check
RunService.Heartbeat:Connect(function(deltaTime)
print(text.Text)
end)
--making the orientationZ be euqal to Label
RunService.Heartbeat:Connect(function(deltaTime)
local orientZ = HRP.Orientation.Z
local orientX = HRP.Orientation.X
text.Text = orientZ
end)
RunService.Heartbeat:Connect(function(deltaTime)
--the if sentence
if text.Text == "0" then Hum.WalkSpeed = Hum.WalkSpeed +1000
elseif Hum.MoveDirection == Vector3.new (0, 0, 0) then Hum.WalkSpeed = Hum.WalkSpeed
end
end)
ok so what I found out the problem was is that you used script.Parent.HumanoidRunning:Connect(function() as a sort of loop
of which the controller denies for some reason.
What you could do to fix that is use another form of loop like RunService.Heartbeat:Connect(function()