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

How do I make the Raycast point in the direction of the Handle? [Not solved]

Asked by 9 years ago
MouseHold = false
local Tool = script.Parent
local User
Tool.Equipped:connect(function(mouse)
     mouse.Icon = "http://www.roblox.com/asset/?id=57571495"
  --mouse.Icon = "http://www.roblox.com/asset/?id=17409601" Epic mouse icon
    User = Tool.Parent
    mouse.Button1Down:connect(function()
            MouseHold = true
            while MouseHold == true do
            wait(0)
        local Ray = Ray.new(Tool.Handle.CFrame.p,((Tool.Handle.CFrame * CFrame.new(0,0,1)).p).unit* 10)  --Problem here
        local Hit,Position = game.Workspace:FindPartOnRay(Ray,User) 
       if Hit then
        if Hit.Parent:FindFirstChild("Humanoid") then 
            Hit.Parent.Humanoid:TakeDamage(2.5)
    end end
        local RayPart = Instance.new("Part",User)
    RayPart.Name = "RayPart" 
    RayPart.BrickColor = BrickColor.new("Bright red")
    RayPart.Transparency = 0.5
    RayPart.Anchored = true 
    RayPart.CanCollide = false 
    RayPart.TopSurface = Enum.SurfaceType.Smooth 
    RayPart.BottomSurface = Enum.SurfaceType.Smooth 
    RayPart.formFactor = Enum.FormFactor.Custom 
    local Distance = (Position-Tool.Handle.CFrame.p).magnitude 
    RayPart.Size = Vector3.new(0.2,0.2,Distance) 
    RayPart.CFrame = CFrame.new(Position,Tool.Handle.CFrame.p) * CFrame.new(0,0,-Distance/2) 
    game.Debris:AddItem(RayPart,0.1) 
   end end)
mouse.Button1Up:connect(function()
MouseHold = false
wait()
end) end)

Answer this question