【发布时间】:2016-03-26 22:47:17
【问题描述】:
我需要一点帮助。基本上我有这个代码:
local plyIsEntered = false
function onTouched(hit)
plyIsEntered = true
if not plyIsEntered then
end
if plyIsEntered then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local ply = humanoid.Parent
if humanoid ~= nil then
print("Hit")
local playerName = hit.Parent.Name
print(playerName)
local laserEmitter = game.Workspace["Enterance PC"]:FindFirstChild("laserEmitter")
local scanLaser = Instance.new("Part", game.Workspace)
scanLaser.Position = laserEmitter.Position
scanLaser.Name = "ScanLaser"
scanLaser.Size = Vector3.new(1,1,1)
local scanLaserMesh = Instance.new("SpecialMesh", game.Workspace.ScanLaser)
scanLaserMesh.Name = "Cone mesh"
scanLaserMesh.MeshType = ""
plyIsEntered = false
end
end
end
script.Parent.Touched:connect(onTouched)
现在我正在检查玩家是否触摸了一个盒子,它没有碰撞并且是不可见的;当他们这样做时,我想创建一个激光来扫描他们并打开一扇门。我遇到的问题是当我走进触发框时,它会创建 8 或 9 个方块。其中一个块是我正在应用网格的块。
我需要做的是确保它只运行一次并且不会创建超过 1 个积木。希望有人可以帮助我!
【问题讨论】:
-
出于某种奇怪的原因,它不允许我编辑...您需要修复代码格式。另外不要忘记 roblox 有自己的 Scripters 论坛,可以帮助解决这些问题。除了建议,.Touched 会触发很多,所以你应该看看 debounce。 wiki.roblox.com/index.php?title=去抖