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

My bullet goes is inaccurate how to fix it?

Asked by
ym5a 52
3 years ago
local Jerry = game.Players.LocalPlayer:GetMouse()  --Localscript
local tool = script.Parent
local origin = script.Parent.meGun.Origins
local debounce = false
local cooldown = 0.2
Jerry.TargetFilter = game.Workspace.Laseronias
Jerry.TargetFilter = origin
script.Parent.Activated:Connect(function()
    if debounce then return end
    debounce = true
    local jerryPos = Jerry.hit.p
    local oPos = origin

    game.ReplicatedStorage.RemoteEvent:FireServer(jerryPos,oPos)
    wait(cooldown)
    debounce = false
end)
local debris = game:GetService("Debris")

--This is the Server Script
local function shootbullet(origin,direction,ting)   
    local part = Instance.new("Part")
    part.Parent = game.Workspace.Laseronias
    part.Material = Enum.Material.Neon
    part.BrickColor = BrickColor.new("Gold")
    part.Size = Vector3.new(0.1,0.1,0.1)
    part.Anchored = true
    part.CanCollide = false
    part.Position = origin.Position
    local startPos = part.Position
    for i = 0,1,0.1 do
        wait()
        part.Position = startPos:Lerp(ting,i)
        print("moved")
        print(ting)
    end
end

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,jP,oP)
    local DEST = (jP-oP.Position).Unit * 999
    local tikn = (jP-oP.Position)
    local Res = workspace:Raycast(oP.Position,DEST)
    local resPart = Res.Instance
    if Res then
        print(Res.Instance.Name)
        if resPart.Parent:FindFirstChild("Humanoid") and resPart.Parent:FindFirstChild("Humanoid") ~= player.Character:FindFirstChild("Humanoid") then
            resPart.Parent:FindFirstChild("Humanoid"):TakeDamage(100)
        end
    end
    shootbullet(oP,DEST,tikn)
end)

So basically where the bullet fires is inaccurate. Here is a clip of what happens: https://gyazo.com/54046a0d5c313f3f7b899ec651476b7c

0
maybe use raycasting sne_123456 439 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

This might be because of network ownership. try setting the network ownership of the bullet to the player holding the gun. For more information. https://developer.roblox.com/en-us/articles/Network-Ownership

0
How would I do this? ym5a 52 — 3y
Ad

Answer this question