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

How do I make a part constantly follow my mouse? (More info in desc)

Asked by 4 years ago

Code:

script.Parent.direF.OnServerEvent:Connect(function(p, mouse)
local plr = p
local char = plr.Character or plr.CharacterAdded:wait()
local hum = char.Humanoid
script.Parent.Parent.Parent.Data.Tries.Value = script.Parent.Parent.Parent.Data.Tries.Value + 50
script.Parent.Parent.Parent.Data.LeftMaina.Value = script.Parent.Parent.Parent.Data.LeftMaina.Value - 40
local AlreadyTouched = false
local trident = game.ReplicatedStorage.Trident:Clone()
trident.Parent = char
trident.BrickColor = BrickColor.new("Bright blue")
trident.Material = Enum.Material.Neon
trident.Anchored = true
trident.CanCollide = false


while true do
    wait()
    trident.CFrame = char.Head.CFrame*CFrame.new(0,2.5,0)
end
end)

In this script I successfully made a hovering trident above my head. The problem here is the trident's pointy part is facing the opposite of what my character is looking at. Another is How do I make that pointy part follow my mouse until I release it for a move?

0
The direction the mouse is relevant to your camera is game.Players.LocalPlayer:GetMouse().UnitRay.Direction. https://developer.roblox.com/en-us/api-reference/property/Mouse/UnitRay pidgey 548 — 4y

Answer this question