我本打算在roblox dev论坛上问这个问题,但他们有一些级别系统的东西。
我写了这段代码,它应该使任何接触“果汁”部分的角色变成不可见的,然后将一个本地脚本复制到他们的玩家角色中,然后等待,然后将它们变为可见并自我销毁。代码只运行一次,但是,如果您再次尝试,事件函数会运行,甚至在每行之后打印,没有错误,但它不会再次更改任何播放器部分的透明度。下面是主脚本。
local healthpack = script.Parent.juice
healthpack.CanCollide = false
healthpack.Anchored = true
healthpack.Touched:Connect(function(hit)
print"hit"
if hit.Parent:FindFirstChild("Humanoid") and healthpack.Transparency ~= 1 then
print"if"
local scrip = script.Parent.LocalScript
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local copy = scrip:Clone()
local tran = .99
local efrem = script.Parent.effectremover:Clone()
print"var"
hit.Parent.LeftFoot.Transparency = tran
print"1"
hit.Parent.LeftHand.Transparency = tran
print"2"
hit.Parent.LeftLowerArm.Transparency = tran
print"3"
hit.Parent.LeftLowerLeg.Transparency = tran
print"4"
hit.Parent.LeftUpperArm.Transparency = tran
print"5"
hit.Parent.LeftUpperLeg.Transparency = tran
print"6"
hit.Parent.LowerTorso.Transparency = tran
print"7"
hit.Parent.RightFoot.Transparency = tran
print"8"
hit.Parent.RightHand.Transparency = tran
print"9"
hit.Parent.RightLowerArm.Transparency = tran
print"10"
hit.Parent.RightLowerLeg.Transparency = tran
print"11"
hit.Parent.RightUpperArm.Transparency = tran
print"12"
hit.Parent.RightUpperLeg.Transparency = tran
print"13"
hit.Parent.UpperTorso.Transparency = tran
print"14"
hit.Parent.Head.Transparency = tran
print"15"
hit.Parent["Pal Hair"].Handle.Transparency = tran
print"16"
efrem.Parent = hit.Parent.Humanoid
print"17"
copy.Parent = player.PlayerGui
print"18"
script.Parent.Heal:Play()
print"19"
healthpack.Transparency = 1
script.Parent.stem.Transparency = 1
script.Parent.bottle.Transparency = 1
script.Parent.cork.Transparency = 1
script.Parent.rim.Transparency = 1
wait(10)
healthpack.Transparency = 0
script.Parent.stem.Transparency = .45
script.Parent.bottle.Transparency = .45
script.Parent.cork.Transparency = 0
script.Parent.rim.Transparency = .35
end
end)发布于 2020-09-20 02:05:30
首先,欢迎来到Stack Overflow!我不能百分之百确定你想要什么,但看起来你的if语句有一个问题,它说的是healthpack.Transparency ~= 1。看起来您正在做的是将透明度设置为.99
local tran = .99然后检查它是否是1
healthpack.Transparency ~= 1因此,如果您更改了if语句:
if hit.Parent:FindFirstChild("Humanoid") and healthpack.Transparency ~= .99 then我建议在if语句之外定义tran变量:
-- Set transparency here instead:
local tran = .99
if (hit.Parent:FindFirstChild("Humanoid") and healthpack.Transparency == tran) then
-- ...
endhttps://stackoverflow.com/questions/63962933
复制相似问题