首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >罗伯克斯试图制造隐形药水,但它只起作用一次。

罗伯克斯试图制造隐形药水,但它只起作用一次。
EN

Stack Overflow用户
提问于 2020-09-19 05:17:05
回答 1查看 218关注 0票数 0

我本打算在roblox dev论坛上问这个问题,但他们有一些级别系统的东西。

我写了这段代码,它应该使任何接触“果汁”部分的角色变成不可见的,然后将一个本地脚本复制到他们的玩家角色中,然后等待,然后将它们变为可见并自我销毁。代码只运行一次,但是,如果您再次尝试,事件函数会运行,甚至在每行之后打印,没有错误,但它不会再次更改任何播放器部分的透明度。下面是主脚本。

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2020-09-20 02:05:30

首先,欢迎来到Stack Overflow!我不能百分之百确定你想要什么,但看起来你的if语句有一个问题,它说的是healthpack.Transparency ~= 1。看起来您正在做的是将透明度设置为.99

代码语言:javascript
复制
local tran = .99

然后检查它是否是1

代码语言:javascript
复制
healthpack.Transparency ~= 1

因此,如果您更改了if语句:

代码语言:javascript
复制
if hit.Parent:FindFirstChild("Humanoid") and healthpack.Transparency ~= .99 then

我建议在if语句之外定义tran变量:

代码语言:javascript
复制
-- Set transparency here instead:
local tran = .99

if (hit.Parent:FindFirstChild("Humanoid") and healthpack.Transparency == tran) then
    -- ...
end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63962933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档