Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"TexureID is not a valid member of MeshPart. Blade2 is not a valid member of model" (but they are)?

Asked by
soutpansa 120
6 years ago

So I've got a script that is supposed to change the TextureID and material of a Part that is in the player when a tool is equipped, but it just gives me the errors in the title of the question. If I add a wait(2), it works, but I can't afford to make it wait to change the part. The part is put into the character with a script when the player equips a tool.

Here's the script that inserts the part:

script.Parent.OtherSwordOn.OnServerEvent:Connect(function(Player)
    if Player.Character:FindFirstChild("Blade2") == nil then
    local RArmWeld = Instance.new("Weld")
    local Box = script.Parent.Parent.Handle:Clone()
    RArmWeld.Parent = Box
    RArmWeld.Part0 = RArmWeld.Parent
    RArmWeld.Part1 = Player.Character.LeftHand
    RArmWeld.C1 = CFrame.new(0, -0.12, -2.5) *CFrame.Angles(0, math.rad(180),math.rad(90))
    Box.Name = "Blade2"
    Box.CanCollide = false 
    Box.Parent = Player.Character
    elseif Player.Character:FindFirstChild("Blade2") ~= nil then
        Player.Character.Blade2:Destroy()
    end
end)

This script works fine for some reason. ^

These next 2 scripts give the errors. I've tried changing them to :FindFirstChild(), but then the script simply doesn't work

script.Parent.Out.OnServerEvent:Connect(function(Player)
    if Player.NonStats.BusoOn.Value == true then
        local Stick = script.Parent.Parent
        Stick.Handle.TextureID = ""
        Stick.Handle.BrickColor = BrickColor.new("Institutional white")
        Stick.Handle.Material = "Neon"
        Player.Character.Blade2.TextureID = ""
        Player.Character.Blade2.BrickColor = BrickColor.new("Institutional white")
        Player.Character.Blade2.Material = "Neon"
        Player.Character.UpperTorso.Buso:Play()
        wait(0.5)
        local P1 = game.ReplicatedStorage["Buso For Sout oWo"].Steam:Clone()
        P1.Parent = Stick.Handle
        local P2 = game.ReplicatedStorage["Buso For Sout oWo"].Steam:Clone()
        P2.Parent = Player.Character.Blade2
        Stick.Handle.BrickColor = BrickColor.new("Really black")
        Stick.Handle.Material = "SmoothPlastic"
        Stick.Handle.Reflectance = 0.1
        Player.Character.Blade2.BrickColor = BrickColor.new("Really black")
        Player.Character.Blade2.Material = "SmoothPlastic"
        Player.Character.Blade2.Reflectance = 0.1
        game:GetService("Debris"):AddItem(P1, 1)
        game:GetService("Debris"):AddItem(P2, 1)
        wait(0.5)
        if Player.NonStats.BusoOn.Value == false then
        Stick.Handle.TextureID = game.ReplicatedStorage.Swords["Dual Katanas"].Handle.TextureId
        Stick.Handle.BrickColor = BrickColor.new("Burnt Sienna")
        Stick.Handle.Material = "Slate"
        Stick.Handle.Reflectance = 0
        Player.Character.Blade2.TextureID = game.ReplicatedStorage.Swords["Dual Katanas"].Handle.TextureId  
        end
    end
end)
script.Parent.OutOff.OnServerEvent:Connect(function(Player)
    if Player.NonStats.BusoOn.Value == false then   
    local Stick = script.Parent.Parent
    Stick.Handle.TextureID = game.ReplicatedStorage.Swords["Dual Katanas"].Handle.TextureId
    Player.Character.Blade2.TextureID = game.ReplicatedStorage.Swords["Dual Katanas"].Handle.TextureId
    end
end)

Thanks for reading! I really need some help with this because it's delaying a feature x.x

1
It's TextureId? User#19524 175 — 6y

1 answer

Log in to vote
3
Answered by 6 years ago
Edited 6 years ago

ok. so why dont u try

(item):FindFirstChild("(itemchildname)") or (item):WaitForChild("(itemchildname)") 

basically if the script fails to find the child(maybe it has not loaded in or what not) then it will call wait for child. calling wait for child by itself might not be good enough(maybe it has already loaded in or what not) and vice versa if u call find first child by itself.

0
can you explain to OP your answer User#19524 175 — 6y
0
ok TheluaBanana 946 — 6y
0
I used WaitForChild, now it isnt giving me an error for Blade2 anymore. It's giving me an error on the last script at line 4. Apparently TextureID isnt a valid member of MeshPart (Stick is the handle of the tool, which is a meshpart) soutpansa 120 — 6y
0
Apparently I used TextureId instead of TextureID. Thanks for the help though! soutpansa 120 — 6y
0
o ok TheluaBanana 946 — 6y
Ad

Answer this question