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

How do I fix crazy block spasm?

Asked by 4 years ago
-- Local Script In StarterPack
local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
local Brick = workspace:WaitForChild("Brick")

Mouse.Move:connect(function()
    Brick.CFrame = Mouse.Hit
end)

Is there anyway to make it not crazy but more of simply on the ground, not inside the ground like when you spawn a part it goes half underground.

https://gyazo.com/46bb72b1bb5c8817b9bc05a83fa4e454 PLEASE WATCH THIS IT SHOWS, INCASE IT DOESNT SHOW, ILL EXPLAIN IT SOME MORE

--- Okay so basiclly what is happening is, I made it so this anchored block in workspace, follows my mouses position, but it keeps floating and zooming into my camera, what I want it to be like is like a building game. You guys know those building games where when your about to place something, it has a transparent block of what you selected, to show where your going to place the block, I want it like that. And for it to not clip through the baseplate or plot.

1 answer

Log in to vote
1
Answered by
Roger111 347 Moderation Voter
4 years ago

Your mouse is hitting the brick itself that you have spawned thus causing it to move it closer and closer to your screen. So the answer to your problem is: You need the mouse to ignore that particular part.

Like so:

-- Local Script In StarterPack
local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
local Brick = workspace:WaitForChild("Brick")
Mouse.TargetFilter = Brick

Mouse.Move:connect(function()
    Brick.CFrame = Mouse.Hit
end)

You can learn more about mouse.TargetFilter here

1
Okay it worked, thanks so much! RandyN56 23 — 4y
0
No problem! Roger111 347 — 4y
Ad

Answer this question