Alright, so I’m making a weapon for my game using FastCast, the problem is that it doesn’t even shoot from the origin.
I used an attachment as the origin and parented it to the weapon, but for some reason the attachment doesn’t change position so the rays are still firing from the attachment’s initial position, and I don’t know how to fix it.
Here’s a video of the bug:
https://gyazo.com/265a3359794d840d49f9e6be1679f561
Here’s the code:
local tool = script.Parent
local Staff = tool:WaitForChild("Staff")
local ShootFrom = Staff:WaitForChild("ShootFrom")
local plrMouse
local activated = nil
local player = game:GetService("Players").LocalPlayer
if not player.Character then player.CharacterAdded:Wait() end
local char = player.Character
local UpperTorso = char:WaitForChild("UpperTorso")
local humanoid = char:WaitForChild("Humanoid")
local ConnectedM6D = UpperTorso:WaitForChild("ToolGrip")
local toolPart1 = tool:WaitForChild("BodyAttach")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Modules = ReplicatedStorage:WaitForChild("Modules")
local ConnectM6D = ReplicatedStorage:WaitForChild("ConnectM6D")
local DisconnectM6D = ReplicatedStorage:WaitForChild("DisconnectM6D")
local ProxyGS = require(Modules:WaitForChild("ProxyGS"))
local staff = ProxyGS.new(tool, 30, ConnectedM6D, toolPart1)
local FireOrigin = ShootFrom.WorldPosition
local FireDirection
local FireSpeed = 150
local FireGravity = Vector3.new(0, 0, 0)
local FireDist = 500
local CanPierce = false
local BulletObj = ReplicatedStorage:WaitForChild("cross")
local container = Instance.new("Folder", workspace)
container.Name = "StaffContainer"
local FireSettings = RaycastParams.new()
FireSettings.FilterType = Enum.RaycastFilterType.Blacklist
FireSettings.FilterDescendantsInstances = {container, char}
local holdAnim = Instance.new("Animation")
holdAnim.AnimationId = "rbxassetid://5626845701"
local hold = humanoid:LoadAnimation(holdAnim)
tool.Equipped:Connect(function(mouse)
print(mouse)
staff:ConnectToTorso()
ConnectM6D:FireServer(tool, 30, ConnectedM6D, toolPart1)
hold:Play()
tool.Activated:Connect(function()
if not activated then
activated = true
plrMouse = mouse
print(FireOrigin)
if plrMouse then
FireDirection = (plrMouse.Hit.Position - FireOrigin).Unit
staff:FireRay(FireOrigin, FireSpeed, FireGravity, FireDirection, FireDist, BulletObj, FireSettings, CanPierce, container)
end
wait(.5)
activated = false
end
end)
end)
tool.Unequipped:Connect(function()
staff:DisconnectFromTorso()
DisconnectM6D:FireServer(tool, 30, ConnectedM6D, toolPart1)
hold:Stop()
end)
And here’s the modulescript I’m using which is based off of FastCast:
function ProxyGS:ShouldPierce()
local function CanRayPierce(cast, rayResult, segmentVelocity)
local hitPart = rayResult.Instance
local hitPoint = rayResult.Position
local normal = rayResult.Normal
local material = rayResult.Material
if material == Enum.Material.Plastic or material == Enum.Material.Ice or material == Enum.Material.Glass or material == Enum.Material.SmoothPlastic then
if hitPart.Transparency >= 0.5 then
.
return true
end
end
return false
end
end
I’ve never had this problem before with the other tools I’ve made, so I’m not sure how to fix it
Help would be appreciated