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

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

Asked by 9 years ago

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

Log in to vote
1
Answered by
Savoron 15
9 years ago

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.

0
Thx Operation_Meme 890 — 9y
Ad

Answer this question