Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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.

Ad
Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

mouse.Hit.p not mouse.p

0
Hi! Thanks for answering but this script is linked to a local script that fires mouse.Hit through FireServer xXKingCool258Xx 39 — 5y
0
Glad u found answer royaltoe 5144 — 5y
0
Thanks for helping tho! xXKingCool258Xx 39 — 5y

Answer this question