What do you want to achieve?
I want the energy ball to have the exploison at the point of collission and then forcefield to have an effect when shot at
What is the issue?
The issue is that the impact effects of the energy ball for some reason don’t show up at the point of collission, instead they show up a bit in the air. On the other hand, the forcefield doesn’t have any effects either sometimes although it gets touched by the orb, although the orb prints that it touched the forcefield. I attached a video of both scenarios. What I found is that on the CLIENT, the position is further however the SERVER finds an earlier position. So although technically it appears that the orb is on the forcefield, the server thinks it’s away from it.
What solutions have you tried so far?
I couldn’t find this exact thing on the DevForum so I tried changing the BodyVelocity to BodyPosition (I know both are deprecated but I don’t know what could substitute BodyVelocity) but that didn’t work. I also tried to add wait() to maybe fix it but it didn’t work either.
script.Parent.OnServerEvent:Connect(function(plr,pos,chr)
local part = Instance.new("Part")
part.Name = "HitBox"
part.Size = Vector3.new(1,1,1)
part.CanCollide = false
part.Anchored = false
part.Position = chr.HumanoidRootPart.Position
part.Parent = workspace
local bodyV = Instance.new("BodyVelocity")
bodyV.Parent = part
bodyV.Velocity = CFrame.new(part.Position, pos).LookVector * 50
part.Touched:Connect(function(hit)
if not hit:FindFirstAncestor(chr.Name) then
bodyV:Destroy()
part.Anchored = true
print(part.Position)
wait()
print(part.Position)
local hitpos = part.Position
part:Destroy()
local part = Instance.new("Part",workspace)
part.Size = Vector3.new(5,5,5)
part.Anchored = true
part.CanCollide = false
part.Position = hitpos
repeat
wait(0.1)
part.Transparency += 0.1
until part.Transparency >= 0.9
part:Destroy()
end
end)
end)
This is purely bare bones for demo
Also for the “print” parts I found that the position printed in this server script is different to the position that is visible when I select the orb from the client POV
You should create the ball on server and send a remote to all clients to tween the orb toward the object, if there are no variables that affect how fast it goes you can send a remote to all clients to tween the ball and wait # seconds on server before executing the code for when it hits
This would also be better alternative as touched isnt a very efficient method for collision detection and can be laggy at times.
No since that would go to the position of the hit part not to the position of where it hit said part. Which isn’t what I want to achieve as it would look weird especially if the object hit was large and the orb hit it at one of the edges.
Yeah but if lets say you specify the tween to take 5 seconds, you can make it that after 5 seconds after the part is created, the code that plays when it collides plays