Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I'm new to scripting, this is my first time using char and nothing works with it just wanna know?

script.Parent.Activated:Connect(function()
    if canForm == true then
    local form = Instance.new("ParticleEmitter")
    form.Texture = "http://www.roblox.com/asset/?id=709137722"
    form.Size = 2
    form.Color = Color3.new(116,81,58)
    wait(0.6)
    canForm = false
    form:Destroy()
    char:FindFirstChild("RightArm").Material = "Corroded Metal"
    char:FindFirstChild("Shirt"):Destroy()
    end
end)

3 comments

0

theres variables above this but this is just the main function

0

What are the variables?

0

canForm is set to true, players is set to localplayer, char is obviously set to character

1 answer

###This is because in the R6 rig of the character, the right arm is called Right Arm, not RightArm. The material is Enum.Material.CorrodedMetal, not "Corroded Metal" with a space. There were a few things you did wrong as well, like using Color3.new without dividing each number by 255.

script.Parent.Activated:Connect(function()
    if canForm then -- no need for == true'
        local form = Instance.new("ParticleEmitter")
        form.Texture = "http://www.roblox.com/asset/?id=709137722"
        form.Size = 2
        form.Color = Color3.new(116/255,81/255,58/255)
        form.Parent = script.Parent.Handle
            -- Assuming this is a tool, I put it in the handle 
        wait(0.6)
        canForm = false
        form:Destroy()
        local ra = char:FindFirstChild("Right Arm")
        
        if ra then
            ra.Material = Enum.Material.CorrodedMetal
        end
    
        local shirt = char:FindFirstChild("Shirt")
        
        if shirt then 
            shirt:Destroy()
        end
    end
end)


###You should also be checking if objects exists via if statements, as code won't work if the object doesn't exist.

This discussion is preserved as it was. New answers, comments, and votes are closed.