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

When I use Mouse.Hit.p it keeps going towards my camera? (Any Fix?)

Asked by 5 years ago

When I use Mouse.Hit.p the part that was created keeps moving towards my camera?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.KeyDown:connect(function(key)
    if key == "1" then
        --//Magnet Release\\--
        if script.Parent.Jutsu.Value == "SandManipulation" then
            local MoveableSand =  game.ReplicatedStorage.Test:Clone()
            MoveableSand.Parent = game.Workspace
            wait(0.1)
            mouse.Button1Down:connect(function()
                for i = 1, 1000 do
                    wait(0.01)
                    MoveableSand.Position = mouse.Hit.p
                end
            end)
        end

Please help?

0
It's the correct behaviour of Mouse.Hit.p; you create the part in the mouse's position, and the part's position becomes the mouse's position. You could try using a condition to ignore the part that was created. LeadRDRK 437 — 5y
0
also mouse.KeyDown is deprecated and works unreliably, use UserInputService instead. LeadRDRK 437 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Try this version of the script. Just changed 2 lines that i noted.


local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key == "1" then --//Magnet Release\\-- if script.Parent.Jutsu.Value == "SandManipulation" then local MoveableSand = game.ReplicatedStorage.Test:Clone() MoveableSand.Parent = game.Workspace wait(0.1) mouse.Button1Down:connect(function() for i = 1, 1000 do wait(0.01) if mouse.Hit.Name ~= "MODELNAMEHERE" then --Add this MoveableSand.Position = mouse.Hit.p end -- And this end end) end
0
mouse.hit is the position of the house, not mouse.Target ;-; User#23365 30 — 5y
0
It doesn't work, but thanks for the help! retrobricks 162 — 5y
Ad

Answer this question