you can see my mouse points in another direction and it point in another for some reason
heres the script
local Idle = script.Idle
local Tool = script.Parent
local Handle = script.Parent.Handle
local Anim:AnimationTrack
local UIS = game:GetService("UserInputService")
local Mouse = game.Players.LocalPlayer:GetMouse()
-- Values
local Ammo = script.Parent.Ammo
local MaxAmmo = script.Parent.MaxAmmo
local Ran = script.Parent.Range
local Dmg = script.Parent.Damage
local RelTime = script.Parent.ReloadTime
Tool.Equipped:Connect(function(m)
Anim = Tool.Parent:WaitForChild("Humanoid").Animator:LoadAnimation(Idle)
Anim:Play()
end)
Tool.Unequipped:Connect(function()
Anim:Stop()
end)
local function Ammoo()
return tonumber(Ammo.Value)
end
local function Reload()
Ammo.Value = "Reloading..."
wait(RelTime)
Ammo.Value = MaxAmmo.Value
end
local event = game.ReplicatedStorage.Shot
local function point(pos,name)
local point = Instance.new("Part",workspace)
point.Anchored = true
point.Size = Vector3.new(1,1,1)
point.Shape = Enum.PartType.Ball
point.Material = Enum.Material.Neon
point.Position = pos
point.CanCollide = false
point.Name = name
end
Tool.Activated:Connect(function()
if Ammoo() > 0 then
Ammo.Value -= 1
local wp = Handle.StartAt.WorldPosition
local dir
Handle.StartAt.Position += Vector3.new(0,0,Ran.Value)
dir = Handle.StartAt.WorldPosition
Handle.StartAt.Position -= Vector3.new(0,0,Ran.Value)
local bulletray = Ray.new(wp,dir) -- making of ray
local part,pos = workspace:FindPartOnRay(bulletray,Handle,true,false)
point(pos,part.Name)
else
Reload()
end
end)
--[[
UIS.InputBegan:Connect(function(i,gpe)
if gpe then return end
if i.KeyCode == Enum.KeyCode.R then
if Ammoo() > 1 then
Reload()
end
end
end)]]
this one is with me positioning another one with ray.Direction
that doesnt cause see the new image i added
only change i did was here
Tool.Activated:Connect(function()
if Ammoo() > 0 then
Ammo.Value -= 1
local wp = Handle.StartAt.WorldPosition
local dir
Handle.StartAt.Position += Vector3.new(0,0,Ran.Value)
dir = Handle.StartAt.WorldPosition
Handle.StartAt.Position -= Vector3.new(0,0,Ran.Value)
local bulletray = Ray.new(wp,dir)
local part,pos = workspace:FindPartOnRay(bulletray,Handle,true,false)
point(pos,"Hit")
point(bulletray.Direction,"Dir")
else
Reload()
end
end)
local RcP = RaycastParams.new()
RcP.FilterDescendantsInstances = {Handle}
Tool.Activated:Connect(function()
if Ammoo() > 0 then
Ammo.Value -= 1
local wp = Handle.StartAt.WorldPosition
local dir
Handle.StartAt.Position += Vector3.new(0,0,Ran.Value)
dir = Handle.StartAt.WorldPosition
Handle.StartAt.Position -= Vector3.new(0,0,Ran.Value)
local bulletray = workspace:Raycast(wp,dir,RcP)
local part,pos = bulletray.Instance,bulletray.Position
visualize(wp,dir)
visualize(wp,pos)
else
Reload()
end
end)