hello ! here is what i want to achieve:
whenever script A is active or toggled it tells script B to stop or disable the script itself
what im encountering right now:
it screws up the rail grinding mechanism:
heres how it should work:
hello ! here is what i want to achieve:
whenever script A is active or toggled it tells script B to stop or disable the script itself
what im encountering right now:
here is script B
NOTE THAT BOTH SCRIPTS USE BODYGYRO
local char = script.Parent
local rootPart = char:WaitForChild(“HumanoidRootPart”)
local xzGyro = Instance.new(“BodyGyro”)
local yGyro = Instance.new(“BodyGyro”)
local RunService = game:GetService(“RunService”)
yGyro.MaxTorque = Vector3.new(0, 3e5, 0)
yGyro.P = 5e5
xzGyro.MaxTorque = Vector3.new(3e5, 0, 3e5)
xzGyro.P = 5e5
xzGyro.Parent = rootPart
yGyro.Parent = rootPart
heres script B messing script A
local smoothFactor = 0.1 – Adjust this value for smoother transitions (lower is smoother)
RunService.RenderStepped:Connect(function(deltaTime)
local params = RaycastParams.new()
params.FilterDescendantsInstances = {char}
params.FilterType = Enum.RaycastFilterType.Blacklist
local result = workspace:Raycast(rootPart.Position, Vector3.new(0, -10, 0), params)
-- Calculate the target CFrame for yGyro
local targetYGyroCFrame = CFrame.new(rootPart.Position, rootPart.Position + char.Humanoid.MoveDirection * 10)
-- Lerp to the target CFrame
yGyro.CFrame = yGyro.CFrame:Lerp(targetYGyroCFrame, smoothFactor)
if result then
local currentRightVector = rootPart.CFrame.RightVector
local upVector = result.Normal
local newFacialVector = currentRightVector:Cross(upVector)
-- Calculate the target CFrame for xzGyro
local targetXZGyroCFrame = CFrame.fromMatrix(rootPart.Position, currentRightVector, upVector, newFacialVector)
-- Lerp to the target CFrame
xzGyro.CFrame = xzGyro.CFrame:Lerp(targetXZGyroCFrame, smoothFactor)
end
end)
Try use BindableEvents/functions
i tried but im kinda new to it so
mind if u wanna collab w/ me? im rlly terrible at bind events…