"Workspace.RedPedastal.Script:17: attempt to index function with 'Transparency'" Roblox 脚本



我正在制作一个roblox脚本,该脚本将传送玩家并制作一个"梁";动画,但当我通过在电传板上行走来激活脚本时,我会得到这个错误

Workspace.RedPedastal.Script:17: attempt to index function with 'Transparency'

代码:

local Teleport = "BeachHill"
local Beam = workspace.Beam
function Beam() #Just here incase of need
for i = 0, 100, 1 do
Beam.Transparency = 1 - i/100
Beam.Size = Vector3.new(2048, 1.8 + i/10, 1.8 + i/10)
print(Beam.Transparency, Beam.Size)
end
end

function Touch (hit)
if script.Parent.Locked == false and script.Parent.Parent : FindFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:FindFirstChild(Teleport).Locked=true
local Pos = script.Parent.Parent:FindFirstChild(Teleport)
hit.parent:moveTo(Pos.Position)
for i = 0, 100, 1 do
Beam.Transparency = Beam.Transparency - 0.01 #<- Error
Beam.Size = Vector3.new(2048, 1.8 + i/10, 1.8 + i/10)
print(Beam.Transparency, Beam.Size)
end     
wait(1)
script.Parent.Locked = false
script.Parent.Parent:FindFirstChild(Teleport).Locked = false
end
end
script.Parent.Touched:connect(Touch)

Lua中的函数和变量位于同一个命名空间中,因此不能在同一个位置同时拥有一个函数和一个变量Beam

最新更新