I’m going to assume from what you’ve provided that you’re calling from the client to the server to get the direction of your kamehame beam. So if you fire a position but move it’s going to delay the position it was before.
I think to fix this you can stop the player from moving first, then get the position using a remotefunction from the server to client to return your position. After that you can do the rest easy peasy.
you understood but how I will be able to do that I am still a beginner in scripting and also (I put my script look at the top please to see if there are any errors)
So since you’re firing the kamehame on the server you should get the position of where your player is on the server. Now make your player stop moving, and do this next step.
Fire a remotefunction on the client to return your mouse’s location and get the hit position, or whatever you do to make the beam go in the direction of where you’re facing.
Once returned on the server you get that position of where your mouse hit, then you stop the player from moving and make the beam go in the direction of the position you returned.
Are you using LookVector? It is very helpful to determine where to shoot the ray, you can use it to determine the direction which the player is facing.
Other than that, you might want to stop the player from changing their character’s orientation. This post will help - How to stop player movement!
local Mouse = Player:GetMouse()
local MousePos = game.ReplicatedStorage:WaitForChild("MousePos") -- or any alternative (mousepos is a remote function
MousePos.OnClientInvoke = function
return Mouse.Hit
end
script
local MousePos = game.ReplicatedStorage:WaitForChild("MousePos")
local MouseHit = MousePos:InvokeClient(player)
"BV.Velocity = MouseHit.LookVector * 150 "--I don't know how to do it from there
Yeah comment out that for loop and see if that fixes the issue and then you can try and move on from there. (You can move the beam on RenderStepped and send a RemoteEvent to all other clients for smooth and efficient movement but that might be too complex for now.)
local MousePos = game.ReplicatedStorage:WaitForChild("MousePos")
local MouseHitCF = MousePos:InvokeClient(player)
if MouseHitCF then
player.Character.Humanoid.WalkSpeed = 0
-- cframe player
Kamehameha.CFrame = MouseHitCF
for i = 1,100 do
-- resize kameha
end
end
Keep in mind this is just an example i’m not going to provide you with the entire code.
Comment out this part of code at the end of Module.Fire function and see if that fixes the issue and then we can try to figure out a solution from there. This code might be breaking the welds you made.
for i, v in pairs(FolderBeam:GetChildren()) do
if v.Name ~= "BeamIn" and v.Name ~= "BeamOut" then
local goal = {}
goal.Size = v.Size + Vector3.new(200,0,0)
goal.CFrame = v.CFrame * CFrame.new(100,0,0)
goal.Anchored = true
Humanoid.AutoRotate = false
local info = TweenInfo.new(6, Enum.EasingStyle.Sine)
local tween = TweenService:Create(v,info,goal)
tween:Play()
end
end
Looking at your vid again It’s safe to assume you’re having weld issues. When you resize your kameha beam it removes it from the weld. You’ll want to use a WeldConstraint most likely as it’s probably adjusted to not break after being resized.
I’m not entirely sure if WeldConstraints break if you resize a part but I doubt it. So if you just weld & position the beam, then resize it you should have no problem.
Alright, I looked at the video again and found the issue. In the loop at the end of the .Fire function, you modify the CFrame but never use LookVector to make it position to the right direction.
An example of LookVector would be:
local Part = Instance.new("Part")
Part.Parent = workspace
Part.Anchored = true
Part.Position = Vector3.new(0,5,0)
while true do
Part.CFrame = Part.CFrame + Part.CFrame.LookVector * 5
wait(1)
end
This will move the part 5 studs in the direction it is facing.
The new for loop code should look like
for i, v in pairs(FolderBeam:GetChildren()) do
if v.Name ~= "BeamIn" and v.Name ~= "BeamOut" then
local goal = {}
goal.Size = v.Size + Vector3.new(200,0,0)
goal.CFrame = v.CFrame + v.CFrame.LookVector * 100
goal.Anchored = true
Humanoid.AutoRotate = false
local info = TweenInfo.new(6, Enum.EasingStyle.Sine)
local tween = TweenService:Create(v,info,goal)
tween:Play()
end
end
for i, v in pairs(FolderBeam:GetChildren()) do
if v.Name ~= "BeamIn" and v.Name ~= "BeamOut" then
local goal = {}
goal.Size = v.Size + Vector3.new(200,0,0)
--goal.CFrame = v.CFrame * CFrame.new(100,0,0)
while true do
goal.CFrame += goal.CFrame.LookVector * 100
wait(1)
end
goal.Anchored = true
Humanoid.AutoRotate = false
local info = TweenInfo.new(6, Enum.EasingStyle.Sine)
local tween = TweenService:Create(v,info,goal)
tween:Play()
end
end
end)
I edited my previous post and provided the code.
You were close but you forgot that it is using TweenService so roblox will handle the positioning for you.
All you have to provide is the final destination.
Since you use TweenService, if the player rotates while the beam is playing, it will not react for it but this will fix the current issue.