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

Why doesn't the "Wood" go to the player's mouse's position?

I have no errors in this script. And it works fine, except the "Wood" doesn't go to the mouses target. Script:

player = game.Players.LocalPlayer
mouse = player:GetMouse()
script.Parent.Selected:connect(function(build)
	l = Instance.new("Part", workspace)
	l.Name = "Wood"
	l.TopSurface = "Smooth"
	l.BottomSurface = "Smooth"
	l.Anchored = true
	l.Transparency = 0.4
	l.BrickColor = BrickColor.new("Brown")
	l.CFrame = CFrame.new(Vector3.new(l.Position, mouse.Target))
end)

1 answer

Line 11 change to:

l.CFrame = CFrame.new(mouse.Hit.p)

Mouse.Target returns an object and you want to put the wood where the mouse is in the 3d space. Mouse.Hit returns the CoordinateFrame of the mouse so using mouse.Hit.p 'p' getting the position at which the mouse is at will fix your problem.

1 comment

0

Thx

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