Hi, I'm struggling to understand how to do this, basically how do I make it so that an object follows your mouse but doesn't move the object in the (x,y) positions only the (z) position? This is my attempted script:
-- Player local Player = game.Players.LocalPlayer local Character = workspace:WaitForChild(Player.Name) local Mouse = Player:GetMouse() -- Services local Storage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") -- Content local Gear = Storage:FindFirstChild("Gear") local Models = Gear:FindFirstChild("Models") local Killer = {} local Model = Models:FindFirstChild("Killer"):WaitForChild("BearTrap"):Clone() Model.Parent = workspace RunService.RenderStepped:Connect(function() local MousePos = Mouse.Hit Model:SetPrimaryPartCFrame(Character.HumanoidRootPart.CFrame * CFrame.new(0, -0.55, Mouse.Hit.p)) end)
Here is the focus:
RunService.RenderStepped:Connect(function() local MousePos = Mouse.Hit Model:SetPrimaryPartCFrame(Character.HumanoidRootPart.CFrame * CFrame.new(0, -0.55, Mouse.Hit.p)) end)
I have tried this and it doesn't work, I have tried other ways and it errors. Is there anyone that can help? If you don't understand I can try to provide examples of what I want it to be like.
Thanks.
RunService.RenderStepped:Connect(function() local MousePos = Mouse.Hit Model:SetPrimaryPartCFrame(Character.HumanoidRootPart.CFrame * CFrame.new(Mouse.Hit.p, Mouse.Hit.p - 0.55, Mouse.Hit.p)) end)
This is my theory: the position is not precisely set and when you multiply by only one axis, it will only move in one direction