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

Projectile falls over head, not sure why?

Asked by 3 years ago

a projectile that i am trying too shoot falls on my head when I shoot it at a wall. shooting at nothing works fine.

https://gyazo.com/90441ec262916cbbd19e76cc27157d42

mouse position fired from localscript

local shadow = game.ServerStorage.MAGICKS:WaitForChild("Shadow")
local shadowDMG = 60

game.ReplicatedStorage.shadowService.OnServerEvent:Connect(function(player, mouse)
    local character = player.Character
    local newShadow = shadow:Clone()
    newShadow.CFrame = character.HumanoidRootPart.CFrame




    local shadowVelocity = Instance.new("BodyForce")
    shadowVelocity.Force = (mouse.Position - character.HumanoidRootPart.Position)
    shadowVelocity.Parent = newShadow



    newShadow.Parent = workspace

    local touchCon

    touchCon = newShadow.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            if hit.Parent.Name ~= player.Name then
                hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - shadowDMG
                if touchCon ~= nil then touchCon:Disconnect() end
                newShadow:Destroy()
            end
        end 
    end)

    wait(4)
    if touchCon ~= nil then touchCon:Disconnect() end
    newShadow:Destroy()
end)


1 answer

Log in to vote
0
Answered by 3 years ago

You should do this with raycasts here is a good explanation: https://devforum.roblox.com/t/how-to-make-a-raycasting-gun/723716

Ad

Answer this question