#how to fix that the tracer thing is spawning outside and its weird
1 messages · Page 1 of 1 (latest)
like its not coming out the barrel
i just want to fix it idk how to
it sapwns at the character since its moving
i gotchu
Tuff
you programmed it that way
goat
so how i fix though
He don’t gotchu
if you want it to actually fire projectiles, you need to code that
Send
no
not projectiles
i just dont want it to spawn so far away
idk
its confusing
Send code in lua format
Ok don’t get help then
what is the expected result
wait u actually gonna help
or u just want the code
ain’t no one tryna steal ur dusty ass raggedy not working script
bro check your dms
It’s a normal question people ask if ur asking for help with ur scripts
ima fix it for u
ok wait theres 2
i will send them
aight
send them to me hes a prince player bum
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)
hes gonna steal your scripts
this is the one u need
morbid the script don’t work
oh right
ok so
make an attatchment at the tip of the gun model and make that the start position instead of shootpart.position
oh wait do you mean the giant gap between the tracer and the gun when you move?
ye
that
u sure thatll fix it?
yes
ill try
He wants it to come out the barrel
what if you traced on the client
shootpart is just a part at thetip of the barrel
i want others to see it though
then do that
mabye it wont work if your already doing this
but try it anyway
and if your using an attachment instead of part you might need to use CFrame
** You are now Level 2! **
yeah
ill test this tomorrow
its late
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
ðŸ˜
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
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.
And then I just do the damage on the server?
Ty
how would i make it start at the position of the attachment
since it doesnt have a position
do i have to like add the cframes
attachment.WorldCFrame.Position
ye i figured it