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

Problem with my mouse activated code?

Asked by 8 years ago

I want this code to create a part whenever a player clicks, and the part to be positioned wherever the players mouse was when they clicked. I don't know if this is possible or not, but I got this error when I tried it myself.

Position is not a valid member of PlayerMouse

Code:

player = game.Players.LocalPlayer
tool = script.Parent
mouse = player:GetMouse()

tool.Activated:connect(function()
    local part = Instance.new("Part")
    part.Anchored = true
    part.Position = Vector3.new(mouse.Position)
end)

tool.Equipped:connect(function()
    mouse.Icon = "http://www.roblox.com/asset/?id=138624641"
end)

tool.Unequipped:connect(function()
    mouse.Icon = ""
end)

Answer this question