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

Why isn't mouse.hit working properly?[Not Fixed]

Asked by 10 years ago

I was making a script that spawns a part (Line 14) where ever the player clicks with the tool,but for some reason it spawns in the middle of the base plate why?

Picture Of Problem

---------------Vairbles---------------
local Tool = script.Parent
local Handle = script.Parent.Handle
local Player = game.Players.LocalPlayer--Gets LocalPlayer(which is the player with tool or script)
local PlayersMouse = Player:GetMouse()--Gets the Players mouse with the GetMouse() method
----------------EquipedEvent-------------
    Tool.Equipped:connect(function(Mouse)
        ---------------------Button1Down---------------------------------
        Mouse.Button1Down:connect(function()--When the player press the right button(Button1) it will do the thing below
            Mouse.Icon  = "http://www.roblox.com/asset/?id=13890082"--Changes the crusor Icon to a plus sign
            Handle.BrickColor = BrickColor.new("Bright green")
            end)
            --------------------Button1Up---------------------------------
            Mouse.Button1Up:connect(function()--When the player releases the right button(Button1) it will do the thing below
                    local Part = Instance.new("Part",game.workspace)
                        Part.Position = Vector3.new(Mouse.Hit)
                Mouse.Icon = ""--Changes the crusor icon back to normal
                Handle.BrickColor = BrickColor.new ("Bright red")
                ------------------------------------------------------------
            end)
    end)

1 answer

Log in to vote
1
Answered by 10 years ago

Try this, I'm not sure , sorry if it doesn't work!

Part.CFrame = CFrame.new(Part.Position,mouse.Hit.p)
end)
0
It didn't work,but thanks kevinnight45 550 — 10y
Ad

Answer this question