Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua 为什么会重复MouseClick事件?_Lua_Roblox - Fatal编程技术网

Lua 为什么会重复MouseClick事件?

Lua 为什么会重复MouseClick事件?,lua,roblox,Lua,Roblox,本地脚本中的鼠标单击事件被复制。每次鼠标单击时,它都会将其注册两次 我正在使用从game.Players.LocalPlayer:GetMouse()中为Mouse.Target接收的两个内置项,但我也使用了库 我有一个加载屏幕脚本,它使用ContextActionService禁用所有控件,还有一个脚本,用于从客户端放入块。是的,我知道它很乱,块只放在客户端而不是服务器上,但它是W.I.P ——块放置脚本 本地玩家=game.Players.LocalPlayer 本地字符=player.Ch

本地脚本中的鼠标单击事件被复制。每次鼠标单击时,它都会将其注册两次

我正在使用从
game.Players.LocalPlayer:GetMouse()
中为
Mouse.Target
接收的两个内置项,但我也使用了库

我有一个加载屏幕脚本,它使用
ContextActionService
禁用所有控件,还有一个脚本,用于从客户端放入块。是的,我知道它很乱,块只放在客户端而不是服务器上,但它是W.I.P

——块放置脚本
本地玩家=game.Players.LocalPlayer
本地字符=player.Character
本地鼠标=需要(script.RbxMouse)
本地bM=player:GetMouse()
本地UserInputService=game:GetService(“UserInputService”)
本地草地=脚本:WaitForChild(“草地”)
本地pe=脚本:WaitForChild(“pe”)
本地tweenService=游戏:GetService(“tweenService”)
本地reachDisplayMod=script.Parent:WaitForChild(“reachDisplayMod”)
本地到达=到达显示模式到达
本地DefaultHardware=require(脚本:WaitForChild(“DefaultHardware”))
本地hardnessGui=游戏。照明:WaitForChild(“hardnessGui”)
本地计数=10000
本地到达时间=0
本地hardnessWaitTime=0
本地sb=脚本:WaitForChild(“SelectionBox”)
本地isMining=false
本地was=零
函数轮(num,numDecimalPlaces)
本地mult=10^(numDecimalPlaces或0)
返回数学楼层(num*mult+0.5)/mult
结束
函数placeBlock(块、向量、ts)
本地bl=块:克隆()
打印(“放置块!”)
如果(ts=“顶部”),则
bl.Hitbox.Position=vector+Vector3.new(0,4,0)
如果(bl.Hitbox:FindFirstChild(“装饰”)),则
bl.Hitbox.Garnish.Position=bl.Hitbox.Position+Vector3.新(0,1.53,0)
结束
bl.Parent=工作区.Blocks
elseif(ts=“前”),然后
bl.Hitbox.Position=vector-Vector3.new(0,0,4)
如果(bl.Hitbox:FindFirstChild(“装饰”)),则
bl.Hitbox.Garnish.Position=bl.Hitbox.Position+Vector3.新(0,1.53,0)
结束
bl.Parent=工作区.Blocks
elseif(ts==“右”)则
bl.Hitbox.Position=vector+Vector3.new(4,0,0)
如果(bl.Hitbox:FindFirstChild(“装饰”)),则
bl.Hitbox.Garnish.Position=bl.Hitbox.Position+Vector3.新(0,1.53,0)
结束
bl.Parent=工作区.Blocks
elseif(ts==“左”),然后
bl.Hitbox.Position=vector-Vector3.new(4,0,0)
如果(bl.Hitbox:FindFirstChild(“装饰”)),则
bl.Hitbox.Garnish.Position=bl.Hitbox.Position+Vector3.新(0,1.53,0)
结束
bl.Parent=工作区.Blocks
elseif(ts==“Back”)则
bl.Hitbox.Position=vector+Vector3.new(0,0,4)
如果(bl.Hitbox:FindFirstChild(“装饰”)),则
bl.Hitbox.Garnish.Position=bl.Hitbox.Position+Vector3.新(0,1.53,0)
结束
bl.Parent=工作区.Blocks
elseif(ts=“底部”)则
bl.Hitbox.Position=vector-Vector3.new(0,4,0)
如果(bl.Hitbox:FindFirstChild(“装饰”)),则
bl.Hitbox.Garnish.Position=bl.Hitbox.Position+Vector3.新(0,1.53,0)
结束
bl.Parent=工作区.Blocks
结束
如果(was~=nil)那么
was:Destroy()
was=零
结束
本地x=sb:Clone()
x、 父项=bl
x、 阿多尔尼=bl
was=x
结束
函数setReach(num)
num=四舍五入(num,2)
reach.Text=tostring(num)
reachWaitTime=reachWaitTime+2
coroutine.wrap(函数()
等待(到达时间)
reach.Text=“0”
(完)
结束
局部函数calcDec(最小值、最大值)
本地值=(最小值/100)/(最大值/100)
返回值
结束
局部函数tween(inst、t、goal)
本地信息=TweenInfo.new(t)
本地tw=tweenService:Create(指令、信息、目标)
tw:Play()
结束
本地功能设置进度(仪表、最小值、最大值)
hardnessWaitTime=hardnessWaitTime+3
如果(inst:FindFirstChild(“HardnessGUI”)),则
本地g=仪表硬件GUI
吐温(g.BarBG.Bar,.2{
尺寸=UDim2.新的(calcDec(最小值,最大值),0,1,0)
})
coroutine.wrap(函数()
等待(hardnessWaitTime)
g:销毁()
(完)
其他的
本地g=hardnessGui:Clone()
g、 父项=指令
吐温(g.BarBG.Bar,.2{
尺寸=UDim2.新的(calcDec(最小值,最大值),0,1,0)
})
coroutine.wrap(函数()
等待(hardnessWaitTime)
g:销毁()
(完)
结束
结束
函数setReach(num)
num=四舍五入(num,2)
reach.Text=tostring(num)
reachWaitTime=reachWaitTime+2
coroutine.wrap(函数()
等待(到达时间)
reach.Text=“0”
(完)
结束
鼠标。按钮[1]。向下:连接(函数()
局部t=bM.目标
如果(t.Name==“Hitbox”),则
本地head=char:FindFirstChild(“head”)
局部位置=(头部位置-t位置)。幅值/4
如果(位置<3或位置==3),则
isMining=true
设置到达(位置)
本地块=t.父块
本地配置=require(块:WaitForChild(“块配置”))
本地bName=conf.Name
局部硬度=块硬度
打印(硬度值)
硬度值=硬度值-1
设置进度(块、硬度值、默认硬度[bName]或5)

if(hardware.Value)请提供一个示例,这是大量看似无关的代码。您能否只发送重要的代码?您可能需要深入RbxMouse库以查看它是否触发其他事件。