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

How to use m.Move:connect() then correctly?

Asked by
816i 19
7 years ago
Edited 7 years ago

so Im trying to lerp a block to my current mouse position but I receive the error Attempt to connect failed: Passed value is not a function at the if m.Move:connect() then.

spawn(function()
    local m = game.Players.LocalPlayer:GetMouse()
    if m.Move:Connect() then
for i = 1, #SoundBlok do
    if i == 1 then
      SoundBlok[i].CFrame = SoundBlok[i].CFrame:lerp(m.Hit, 0.1)
    end
  end
for i = 1, #SoundBlok2 do
    if i == 1 then
      SoundBlok2[i].CFrame = SoundBlok2[i].CFrame:lerp(m.Hit, 0.1)
    end
  end
    end
end)
end)

This works but the errors slowly cause your game to lag out and eventually freeze

How would I go about fixing this? I've tried many things

0
Your problem is line 3: You tried to create a function in the if statement. XP To fix this, just rewrite it as a function + event duo, or anonymous function. :) Also, I would recommend putting waits in the for loops to prevent that "lag," if that's what's causing that. TheeDeathCaster 2368 — 7y

1 answer

Log in to vote
-1
Answered by
Filipalla 504 Moderation Voter
7 years ago
spawn(function()
    local m = game.Players.LocalPlayer:GetMouse()
    m.Move:connect(function()
for i = 1, #SoundBlok do
    if i == 1 then
      SoundBlok[i].CFrame = SoundBlok[i].CFrame:lerp(m.Hit, 0.1)
    end
  end
for i = 1, #SoundBlok2 do
    if i == 1 then
      SoundBlok2[i].CFrame = SoundBlok2[i].CFrame:lerp(m.Hit, 0.1)
    end
  end
    end
end)
end)

Try this it may not be 100% right cus i wrote it in da browser

0
It works but now it doesnt lerp 816i 19 — 7y
0
What was the reasoning behind your answer? What was wrong with the original? Dude, don't just post code: doesn't help anyone. ;/ TheeDeathCaster 2368 — 7y
Ad

Answer this question