#Not the results I wanted
22 messages · Page 1 of 1 (latest)
local function Params()
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {tool.Parent,tool}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true
return raycastParams
end
tool.Activated:Connect(function()
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
local character = player.Character
local mousePos = Mid:InvokeClient(player)
local params = Params()
local direction = (Vector3.new(mousePos) - handle.Position).Unit * range
local raycastresult = workspace:Raycast(handle.Position,direction,params)
if raycastresult then
print(raycastresult.Instance)
local midpoint = (handle.Position - direction)/2
local part = Instance.new("Part",workspace)
part.Size = Vector3.new(0.1,0.1,direction.Magnitude)
part.CFrame = CFrame.new(midpoint,raycastresult.Position)
part.Color = Color3.fromRGB(255, 85, 0)
part.Material = "Neon"
part.Anchored = true
part.CanCollide = false
end
end)
I wanted the bullets aka parts to shoot perfectly but it gives me something like this
why is your direction multiplied by ur range
thats weird
usually direction is normalized
I used.Unit
It gives the direction with the length / magnitude of 1
I multiplied it by the range so for example I want the range to be 100
The max range of the ray will be 100
yes. i know
.
i mean a variable named direction
is usually normalized
and is then multiplied
I fixed it in the new script