Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't my ray change directions? (More info in desc)

Code:

for i = 1,3,1 do
	local ray = Ray.new(char.HumanoidRootPart.CFrame.p, mouse.p)
	local trident = game.ReplicatedStorage.Trident:Clone()
	trident.BrickColor = BrickColor.new("Bright blue")
	trident.Material = Enum.Material.Neon
	trident.CanCollide = false
	trident.CFrame = char.HumanoidRootPart.CFrame*CFrame.new(0,3,0)
	trident.CFrame = CFrame.new(trident.CFrame.p,mouse.p)*CFrame.Angles(0,math.rad(180),0)
	trident.Parent = char
	
	local BV = Instance.new("BodyVelocity")
	BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	BV.Velocity = ray.Direction*1
	BV.Parent = trident
	wait(2)
end

FOR LOOPS. I've been trying to figure out the problem but I'm still just a beginner. In this code the trident should have different directions depending on where the mouse is pointed at, right? WELL NO! MY TRIDENTS HAVE DECIDED TO FOLLOW THE FIRST POSITION THEY WENT THROUGH. How do I fix this?

2 answers

✓ Accepted answer

So I found out why it was only facing one direction. I checked the local script and the problem was there. The local script fires the

event:FireServer(mouse.Hit)

only once, thus causing the problem.

mouse.Hit.p not mouse.p

3 comments

0

Hi! Thanks for answering but this script is linked to a local script that fires mouse.Hit through FireServer

0

Glad u found answer

0

Thanks for helping tho!

This discussion is preserved as it was. New answers, comments, and votes are closed.