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

This way of detecting if mouse.Hit got changed doesn't work, how do i fix it?

Asked by
Echtic 128
4 years ago

I don't mind changing the way i do it, i just need something that works

--- there is a lot more to the script above this
local mouse = player:GetMouse()
local mh = mouse.Hit

    ev:FireServer(mh)

local currentmh = mh

mouse:GetPropertyChangedSignal("Hit"):Connect(function()

    if(mh ~= currentmh)then

        mh = mouse.Hit

        currentmh = mh

     print("hit changed")



    wait()
    ev2:FireServer(mh)
    end

    end)
0
are you sure you dont need the mouse position? ReallyUnikatni 68 — 4y
0
are you sure you dont need the mouse position? ReallyUnikatni 68 — 4y
0
guess the position can work too Echtic 128 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

GetPropertyChangedSignal was disabled for Hit because it'd update way too often, IIRC.

You can try and use a loop in RenderStepped to check for it, specifically after user input (Priority 100)

--NOTE: untested
local mouse = game:GetService"Players".LocalPlayer:GetMouse()
local mh = mouse.Hit
ev:FireServer(mh)
local currentmh = mh
game:GetService"RunService":BindToRenderStep("MHUpdate",Enum.RenderPriority.Input.Value + 1,function()
    mh=mouse.Hit
    if(mh ~= currentmh)then
        mh = mouse.Hit
        currentmh = mh
        print("hit changed")
        wait()
        ev2:FireServer(mh)
    end
end)

See the articles below for some more info.

https://developer.roblox.com/en-us/api-reference/function/RunService/BindToRenderStep

https://developer.roblox.com/en-us/api-reference/function/RunService/UnbindFromRenderStep

https://developer.roblox.com/en-us/api-reference/event/RunService/RenderStepped

Ad

Answer this question