I am making a game where you basically play as a crew member in a Formula 1 team, but I ran into a problem. I am trying to make an Arrow pointing at a part, but don’t know where to start neither do I know how to script it. I have searched around the whole devforum, YouTube and Google. None of those made clear how to do this, except the devforum told me to make something called a beam creation part, which I don’t exactly know what it means.
Thanks for helping in advance
There’s multiple ways to do this but the easiest way I could say would be BodyGyro
I suggest using CFrames;
local part = workspace.Part -- part which it looks at
local arrow = script.Parent -- arrow which points at the part
arrow.CFrame = CFrame.new(arrow.Position, part.Position)
1 Like
Should I make the arrow a GUI in StarterGui?
I mean you could if you’re using GUI instead of an arrow part
But GUI would be a little bit more difficult if you aren’t familiar with it and coding GUIs.
Well, I actually do mostly specialize in GUI’s so I do think that would be possible. But, how should I use an Arrow part?
If you were to use a part it would be easier by using KJry_s code below.
local part = workspace.Part -- part which it looks at
local arrow = script.Parent -- arrow which points at the part
arrow.CFrame = CFrame.new(arrow.Position, part.Position)
But if you use a part make sure the front surface is where the arrow is pointing or it wouldn’t look right.
I suggest locking the part onto the player’s camera after which you point the camera at a certain part.
E.g.:
-- Local Script in StarterPlayer.StarterPlayerScripts
local runService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local part = workspace.Part
local arrow = script.Arrow
local offset = Vector3.new(10,1,0)
player.CharacterAdded:Connect(function(character)
runService.HeartBeat:Connect(function()
if character and character:FindFirstChild("Humanoid") and character.Humanoid.Health ~= 0 then
arrow.CFrame = CFrame.new((Camera.CFrame + offset).position, part.Position)
else
arrow.Position = Vector3.new(0,-10,0) -- hide the arrow
return -- if im right this should stop the loop, otherwise if you'd reset you'd still have this running and another one, the valid one, else you should remove this line.
end
end)
end)
1 Like