#how to fix that the tracer thing is spawning outside and its weird

1 messages · Page 1 of 1 (latest)

craggy flax
#

like its not coming out the barrel

#

i just want to fix it idk how to

#

it sapwns at the character since its moving

visual owl
#

i gotchu

frank haven
steep minnow
craggy flax
craggy flax
frank haven
steep minnow
#

if you want it to actually fire projectiles, you need to code that

frank haven
craggy flax
#

not projectiles

#

i just dont want it to spawn so far away

#

idk

#

its confusing

frank haven
#

Send code in lua format

craggy flax
#

no bro

frank haven
#

Ok don’t get help then

steep minnow
craggy flax
#

or u just want the code

frank haven
#

ain’t no one tryna steal ur dusty ass raggedy not working script

visual owl
#

bro check your dms

frank haven
#

It’s a normal question people ask if ur asking for help with ur scripts

visual owl
#

ima fix it for u

craggy flax
#

i will send them

frank haven
#

aight

visual owl
#

send them to me hes a prince player bum

craggy flax
#
local shootEvent = game.ReplicatedStorage.Remotes:FindFirstChild("pistol shoot")

local tool = script.Parent
local handle = tool.Handle
local shootPart = handle.Shoot

local function CreateTracer(startPos, endPos, color)
    local tracer = Instance.new("Part")
    tracer.Anchored = true
    tracer.CanCollide = false
    tracer.Material = Enum.Material.Neon
    tracer.Color = color or Color3.new(1, 1, 0) -- default to yellow
    tracer.Transparency = 0.2

    local distance = (endPos - startPos).Magnitude
    tracer.Size = Vector3.new(0.1, 0.1, distance)
    tracer.CFrame = CFrame.new(startPos, endPos) * CFrame.new(0, 0, -distance / 2)
    tracer.Parent = workspace

    -- Auto-remove after 0.1 seconds
    game:GetService("Debris"):AddItem(tracer, 0.05)
end

shootEvent.OnServerEvent:Connect(function(plr, mousePos)
    handle.Gunshot:Play()
    local rayParams = RaycastParams.new()
    rayParams.FilterDescendantsInstances = {plr.Character}
    rayParams.FilterType = Enum.RaycastFilterType.Exclude
    
    local raycastResult = workspace:Raycast(shootPart.Position, (mousePos - shootPart.Position) * 300, rayParams)
    if raycastResult then
        CreateTracer(shootPart.Position, raycastResult.Position)
        local raycastInstance = raycastResult.Instance
        local model = raycastInstance:FindFirstAncestorOfClass("Model")
        
        if model then
            if model then
                if model:FindFirstChild("Humanoid") then
                    if raycastInstance.Name == "Head" then
                        model.Humanoid:TakeDamage(30)
                    else
                        model.Humanoid:TakeDamage(10)
                    end
                end
            end
        end
    else
        local direction = (mousePos - shootPart.Position).Unit
        local maxDistance = 300 -- how far the bullet goes if it hits nothing
        CreateTracer(shootPart.Position, shootPart.Position + direction * maxDistance)
    end

end)
visual owl
#

hes gonna steal your scripts

craggy flax
#

this is the one u need

frank haven
#

morbid the script don’t work

craggy flax
#

it works

#

i just want to fix that one thing

frank haven
#

oh right

visual owl
#

ok so

#

make an attatchment at the tip of the gun model and make that the start position instead of shootpart.position

steep minnow
craggy flax
visual owl
#

yes

craggy flax
#

ill try

frank haven
steep minnow
#

what if you traced on the client

craggy flax
#

shootpart is just a part at thetip of the barrel

craggy flax
steep minnow
visual owl
#

but try it anyway

#

and if your using an attachment instead of part you might need to use CFrame

empty falconBOT
#

studio** You are now Level 2! **studio

craggy flax
#

ill test this tomorrow

#

its late

visual owl
#

alright

#

bro i learned dont script late the hard way

#

i spent an entire hour trying to figure out why my moves wasnt working and i realized i never had a remote event

blazing tendon
# craggy flax

dont do it on the server since it looks like some server lag (if your doing it in a roblox game server) affecting the raycast, raycast from client, make sure its an attachment

#

its also generally better for raycasts and the visuals to be on the client

still lagoon
# craggy flax

The offset is because the tracer is being spawned at the location of your character on the server which always lags behind by a bit.

The solution is to spawn the tracer locally on the client when you click. To replicate the tracer to other players, the server should send an event to everyone except for the player who shot (since they already spawned a tracer right when they clicked) and provide the position the tracer ends at and the part/attachment the tracer starts from. Then when the client receives the message to create the tracer, spawn a tracer between the provided part/attachment's position and the provided destination position.

craggy flax
craggy flax
#

since it doesnt have a position

#

do i have to like add the cframes

still lagoon
craggy flax