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:

01wait(2)
02 
03workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
04 
05local mouse = game.Players.LocalPlayer:GetMouse()
06local wplr = game.Players.LocalPlayer.Character
07 
08while game:GetService("RunService").Heartbeat:Wait() do
09    wplr = game.Players.LocalPlayer.Character
10    mouse.TargetFilter = wplr
11    workspace.EndPart.Position = mouse.Hit.p
12    local distance = (wplr.RightHand.Position - mouse.Hit.p).magnitude
13    workspace.BeamPart.Size = Vector3.new(0.3, 0.3, distance)
14    workspace.BeamPart.CFrame = CFrame.new(wplr.RightHand.CFrame.p, mouse.Hit.p) * CFrame.new(0, 0, -distance / 2)
15end

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.

01wait(2)
02 
03workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
04 
05local mouse = game.Players.LocalPlayer:GetMouse()
06 
07 
08 
09while game:GetService("RunService").Heartbeat:Wait() do
10    local wplr = game.Players.LocalPlayer.Character
11    mouse.TargetFilter = workspace.Parts
12    workspace.Parts.EndPart.Position = mouse.Hit.p
13    local distance = (wplr.RightHand.Position - mouse.Hit.p).magnitude
14    workspace.Parts.BeamPart.Size = Vector3.new(0.3, 0.3, distance)
15    workspace.Parts.BeamPart.CFrame = CFrame.new(wplr.RightHand.CFrame.p, mouse.Hit.p) * CFrame.new(0, 0, -distance / 2)
16end
Ad

Answer this question