Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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:

3 comments

0

Line is is a repeat thing you know right?

0

Line 8*

0

So, its going to keep on getting bigger...

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.