Earlier this morning I was coding a small arrow system that can be used as a remote event, and noticed this weird thing happening.
The arrow beam seemed to be facing the wrong way. This is a problem as when I use it on everyone in-game, it’ll most likely confuse the players; which isn’t ideal.
local RunService = game:GetService("RunService")
local ArrowEvent = Functions_And_Events.VisualsEvents:WaitForChild("ArrowsEvent")
local Player = game.Players.LocalPlayer
ArrowEvent.OnClientEvent:Connect(function(Target)
if Player.Character then
local attachment_player
local attachment_target = Instance.new("Attachment")
local arrowsBeam
if Player.Character.PrimaryPart:findFirstChild("Attachment") then -- Create player attachment
attachment_player = Player.Character.PrimaryPart.Attachment
arrowsBeam = attachment_player.ArrowsBeam
else
attachment_player = Instance.new("Attachment")
attachment_player.Parent = Player.Character.PrimaryPart
arrowsBeam = game.ReplicatedStorage.Stage_Assets.ArrowsBeam:Clone()
arrowsBeam.Parent = attachment_player
arrowsBeam.Attachment1 = attachment_player
end
if Target:IsA("Model") then -- Create Target Attachment
attachment_target.Parent = Target.PrimaryPart
arrowsBeam.Attachment0 = attachment_target
else
attachment_target.Parent = Target
arrowsBeam.Attachment0 = attachment_target
end
spawn(function()
wait(1)
local connection
connection = RunService.RenderStepped:Connect(function() -- Remove attachments when reaching point
if Player.Character then
if Player:DistanceFromCharacter(Target.Position) < 10 then
print(Player:DistanceFromCharacter(Target.Position))
attachment_target:Destroy()
attachment_player:Destroy()
connection:Disconnect()
end
end
end)
end)
end
end)
Is there anything I should do differently? I’m pretty stuck.
Here is also how I store my beams in ReplicatedStorage.
Any help is appreciated, thank you
[Example below]: