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

Parts just keep getting bigger even though im not editing size?

Asked by 6 years ago

Alright so! I am trying to make a system so where-ever your mouse is pointing a part as made and points towards that but if I keep my mouse still the parts come towards the camera. I have tried position, cframe, anchoring, un-anchoring and none of them work.

Code:

wait(2)

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

local mouse = game.Players.LocalPlayer:GetMouse()
local wplr = game.Players.LocalPlayer.Character

while game:GetService("RunService").Heartbeat:Wait() do
    wplr = game.Players.LocalPlayer.Character
    mouse.TargetFilter = wplr
    workspace.EndPart.Position = mouse.Hit.p
    local distance = (wplr.RightHand.Position - mouse.Hit.p).magnitude
    workspace.BeamPart.Size = Vector3.new(0.3, 0.3, distance)
    workspace.BeamPart.CFrame = CFrame.new(wplr.RightHand.CFrame.p, mouse.Hit.p) * CFrame.new(0, 0, -distance / 2)
end

Thanks for reading have a nice day! c:

0
Line is is a repeat thing you know right? kittonlover101 201 — 6y
0
Line 8* kittonlover101 201 — 6y
0
So, its going to keep on getting bigger... kittonlover101 201 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

The part's size isn't changing, the part is spazzing out and getting closer to the camera because the mouse's target is the part itself.

What you should do is group the two parts (BeamPart and EndPart) together into a group (in my code, called "Parts") and set the TargetFilter to that. It should take higher priority than the character.

wait(2)

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

local mouse = game.Players.LocalPlayer:GetMouse()



while game:GetService("RunService").Heartbeat:Wait() do
    local wplr = game.Players.LocalPlayer.Character
    mouse.TargetFilter = workspace.Parts
    workspace.Parts.EndPart.Position = mouse.Hit.p
    local distance = (wplr.RightHand.Position - mouse.Hit.p).magnitude
    workspace.Parts.BeamPart.Size = Vector3.new(0.3, 0.3, distance)
    workspace.Parts.BeamPart.CFrame = CFrame.new(wplr.RightHand.CFrame.p, mouse.Hit.p) * CFrame.new(0, 0, -distance / 2)
end
Ad

Answer this question