2016-08-20 6 views
0

のように、私はそれを行うことができますスクリプトを探しています。誰かがこのスクリプトを修復することができれば、私は幸せになるでしょう:Dどのプレイヤーは、彼がレンガタッチ特定のTシャツ着るかどうかを検出 - タイトルに[ROBLOX LUA]

function onTouched(part) 
local h = part.Parent:findFirstChild("Humanoid") 
if h ~= nil then 
    if player.parent.torso.roblox.Texture == "https://web.roblox.com/Bloxxer-item?id=1028595" then 
     script.Parent.Check.Transparency = 0 
     wait (2) 
     script.Parent.Check.Transparency = 1 
    end 
end 

エンド script.Parent.Touched:あなたは何をしたいんどちらかのことをどのfree-modelを見つけることができない場合は、(onTouched)

答えて

0

を接続したり、編集可能です。ここで私達は行く:

私たちはしばしばscript.Parentを参照しているため、variableを行うことができます:

local Block = script.Parent 

また、あまりにもそのための変数を作ることによって、コード本体内のURLのような定数を置くことを避けることができます:

local TShirtTexture = "http://www.roblox.com/asset/?version=1&id=1028594" 

Tシャツのテクスチャリンクがアイテムリンクと異なる点に注意してください。私はBloxxerテクスチャがhttp://www.roblox.com/asset/?version=1&id=1028594だと思います。リンクを見つけるには、上のTシャツとinspect我々はまた、あなたが本当に外にそれを参照する必要がない場合debouncer

が、私はanonymous functions方が好き必要

Tシャツとスタジオでゲームに参加:一部が触れた後、削除された場合は、コードが実行される前に、あなたが撮影した場合、それは(最初に破るために使用されるいくつかのVIPのドアを、それをチェックするのが最善ですpart.Parentnilかもしれないよう

Block.Touched:connect(function(Part) 
    -- code goes here 
end) 

ラインpart.Parent:findFirstChildは、安全でないかもしれませんこれのために彼らに)。他のものと同じですが、それが存在することを確認してください。そうでなければ、ある時点でコードが壊れる可能性があります。

次に、文字Torsoを大文字にしています。また、Tシャツはキャラクターの中にあり、プレーヤーではありません。そして、いくつかの変数で一緒に

そして最後にすべてを投げる:

-- Put some variables 
local Block = script.Parent 
local TShirtTexture = "http://www.roblox.com/asset/?version=1&id=1028594" 

-- Debounce variable 
local Debounce = false 

-- Use anonymous function 
Block.Touched:connect(function(Part) 
    -- Assume that the Part is a BodyPart, thus the parent should be the character 
    local Character = Part.Parent 

    -- Ensure that our assumption is correct 
    if Character == nil or Character:findFirstChild("Humanoid") == nil then return end 

    -- Reference to the assumed Torso 
    local Torso = Character:findFirstChild("Torso") 

    -- Ensure that it exists 
    if Torso == nil then return end 

    -- Reference to the assumed T-Shirt 
    local TShirt = Torso:findFirstChild("roblox") 

    -- Ensure that it exists, and that it is a Decal (T-Shirts are decals) 
    if TShirt == nil or not TShirt:IsA("Decal") then return end 

    -- Ensure the texture is correct 
    if TShirt.Texture ~= TShirtTexture then return end 

    -- Check debounce 
    if Debounce then return end 
    Debounce = true 

    -- Do stuff 
    Block.Check.Transparency = 0 
    wait (2) 
    Block.Check.Transparency = 1 

    Debounce = false 
end) 

そして、あなたはプレイヤーがアイテムを所有しているかどうかを確認ではなく、それを着用する必要があるにしたい場合は、check this out

また、スクリプトの場合動作しません、私は私の世界でそれを試してみて、スクリプトが動作していない関連errors

+0

を投稿することを忘れないでください。 TシャツIDを少し変更して、エラーがあるかどうかを確認しようとしましたが、まだ動作していません。 – AirportStaff

+0

@AirportStaff間違いはありますか? Block.Checkは正しいですか?通常はあなたはパーツパーツを持っていません – ZombieSpy

+0

私は理由はわかりませんが、誰かが私の質問を編集し、 "チェック"を追加します。なぜなら私の最初の質問にはなかったからです。しかし、どうもありがとう、私は "チェック"を削除し、今それは働いている! – AirportStaff

関連する問題