local distance = 2
ball.Position = ball.Position + ball.CFrame.LookVector * distance
maybe that?
local distance = 2
ball.Position = ball.Position + ball.CFrame.LookVector * distance
maybe that?
what’s the ball’s orientation?
could you screenshot all of the part’s properties? I’ll try to fix that inside studio
The original orientation?
It’s 0,0,0
When it’s cloned to the Workspace, the ball’s orientation follows the Character’s HumanoidRootPart.Orientation.
Thanks! I tried this one.
Well it works on the Server-side
When i tried to run it on the Client-Side, it moves in -Z-Direction only
To clear confusion: when you want the negative ZVector, use CFrame.LookVector
. This is the equivalent of calculating the negative ZVector.
I got 2 scripts to make the ball animation.
1 which is a normal script is planted in PLayer’s Character
1 another which is a localscript is planted in Player’s Script folder.
I suspect that the localscript read the bal’s Orientation as 0,0,0
making it move awkwardly
what’s the orientation when it appears infront of char
Why not try lerping to a high number of studs away, putting the ability in debris to delete itself?
It follows the HumanoidRootPart’s Orientation (wherever you go as what i shown in the video)
0,0,0
in the client
0, -56.1,0
) in the server
I don’t get it easily, can you give me some sort of examples?
I used vector3 instead of CFrame and it worked.
Lerping returns a CFrame interpolation between the origin CFrame and a goal CFrame by a fraction.
Determine a destination CFrame, let’s go with:
local destination = HumanoidRootPart.CFrame + HumanoidRootPart.CFrame.LookVector * 5000
Next, we spawn the part and lerp it (and debris).
local debris = game:GetService("Debris")
local HumanoidRootPart = --you know what to do here
local lastingTime = 5 --destroys after 5 seconds
local ball = workspace.LightBall
--lerping code:
local function sendBall()
local clone = ball:Clone()
local start = HumanoidRootPart.CFrame + HumanoidRootPart.CFrame.LookVector * 10
local destination = HumanoidRootPart.CFrame + HumanoidRootPart.CFrame.LookVector * 5000
clone.Parent = workspace
debris:AddItem(clone, lastingTime)
clone:PivotTo(start)
for i = 0, 1, 0.0002 do
clone:PivotTo(start:Lerp(destination, i))
end
end
You can change the 0.0002 in the for loop to modify speed.
0.0002 is 1 stud/s.
can you give me the samples? ill try it in the studio
I just did it:
and it worked.
This would rely on the ball travelling towards the X axis.
well but isn’t it the main point? we want it to move forwards
is it a server script to client script? my client always read the ball’s orientation as0,0,0
it’s only server script, nothing more
didnt really read thru it well but heres what i think would fix the problem
if its a local script:
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Speed = 0.1
Remote.OnClientEvent:Connect(function(ball)
-- Wait until the character is loaded and the HumanoidRootPart is available
local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
while ball and humanoidRootPart do
-- Calculate the forward direction based on where the humanoid root part is facing
local forward = humanoidRootPart.CFrame.LookVector
-- Update the ball's CFrame to move it forward in the direction the character is facing
ball.CFrame = ball.CFrame * CFrame.new(forward * -1) -- Multiplying by -1 to move forward
task.wait(Speed)
end
end)
if server sided:
local Players = game:GetService("Players")
local Speed = 0.1
local remoteEvent = game.ReplicatedStorage:WaitForChild("MoveBallEvent") -- Ensure this exists in ReplicatedStorage
-- Function to move the ball forward relative to player's facing direction
local function moveBall(player, ball)
-- Wait until the character is loaded and the HumanoidRootPart is available
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
-- Move the ball
while ball and humanoidRootPart do
-- Calculate the forward direction based on where the humanoid root part is facing
local forward = humanoidRootPart.CFrame.LookVector
-- Update the ball's CFrame to move it forward in the direction the character is facing
ball.CFrame = ball.CFrame * CFrame.new(forward * -1) -- Multiplying by -1 to move forward
wait(Speed)
end
end
-- Connect the RemoteEvent to handle requests from clients
remoteEvent.OnServerEvent:Connect(function(player, ball)
moveBall(player, ball)
end)
trigger(server)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("MoveBallEvent")
local ball = script.Parent -- assuming this script is a child of the ball or has some way to reference it
-- Example trigger, such as a GUI button click or a keyboard event
local function onTrigger()
remoteEvent:FireServer(ball)
end
-- Connect the trigger to your event
script.Parent.MouseButton1Click:Connect(onTrigger) -- Adjust based on actual triggering method
I saw you said something about using local script to maximize physics, but you can also use this: part:SetNetworkOwner(player)
basically gives you an permition to treat a part and “control” it as it would be your local part.