I get the following error when running these scripts: "cannot resume non-suspended coroutine"

its a remote function. the server script reads

local press = Instance.new("RemoteFunction")
press.Parent = script.Parent
press.Name = "FetchMousePressed"
script.Parent.Equipped:wait()
player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local buttonpressed = function()
	return press:InvokeClient(player)
end

and the local script, which does the work, reads

local Mouse = game.Players.LocalPlayer:GetMouse()
 
script.Parent:WaitForChild("FetchMousePressed").OnClientInvoke = function()
	Mouse.Button1Down:connect(function()
	local Fire = true
	
	Mouse.Button1Up:connect(function()
		Fire = false
	end)
	
	return Fire
end)
end

any ideas?

2 comments

0

I believe it is the fact you instantiated a local variable in a function. Notice the "local Fire." Think about what is happening with it.

0

it should be being updated according to the user's mouse, if its being clicked or not.