Roblox change body part color script

Asked by

4 years ago

Edited 4 years ago

Hi, I tried making a script that changes a players color when they click F. But for some reason this error keeps on showing up:

18:53:10.311 - ContextActionService: Unexpected error while invoking callback: Players.turbomegapower12345.PlayerGui.ZeusPowers:42: attempt to index global 'RightArmColor' (a nil value)

Here is my script:

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:Wait() 
local head = character:WaitForChild("Head")

local Humanoid = character:WaitForChild("Humanoid")
local torso = character.UpperTorso
local mouse = player:GetMouse()

local bodycolors = character:WaitForChild("Body Colors")


local Workspace = game.Workspace


local target



local God = player.PlayerGui.ChooseCharacter.God
--BREAKLINE--

local function onKeyPress(actionName, userInputState, inputObject)
    target = mouse.Target
    if userInputState == Enum.UserInputState.Begin then
    if inputObject.KeyCode.Name =="T" then
        if God.Value =="Zeus" then
            game:GetService("Chat"):Chat(player.Character.Head, "MASTERBOLT!","Blue")
            local tool = game.Workspace.BetaBolt:Clone()
            character.Humanoid:EquipTool(tool)
            wait(5)
            tool:Destroy()

        end
    end



       if inputObject.KeyCode.Name =="F" then
        if God.Value =="Zeus" then
        game:GetService("Chat"):Chat(player.Character.Head, "FEEL THE POWER OF A TRUE GOD!","Blue")
        Humanoid.HipHeight = 20
        bodycolors.RightArmColor = ("Dark blue")

        wait(6)
        --end of power--

        Humanoid.HipHeight = 1.35
        end
    end

    if inputObject.KeyCode.Name =="Q" then
        if God.Value == "Zeus" then
            game:GetService("Chat"):Chat(player.Character.Head, "LIGHTNING DASH!","Blue")
            head.CFrame = head.CFrame * CFrame.new(0,0,-50)
        else
            print("FAIL LIGHTNING DASH")

        end
    end


    if inputObject.KeyCode.Name =="E" then
         if God.Value == "Zeus" then  
            game:GetService("Chat"):Chat(player.Character.Head, "THUNDER!","Blue")
            local damage = game.Workspace.Damage:Clone()
            local Thunder = Instance.new("Part")
            Thunder.Name = ("ThunderBolt")
            local mesh = Instance.new("SpecialMesh",Thunder)
            mesh.MeshId = "rbxassetid://978945957"
            mesh.TextureId = "rbxassetid://978945981"
            Thunder.Anchored = true
            Thunder.Orientation = Vector3.new(0,0,0)
            mesh.Scale = Vector3.new(5,20,15)
            damage.Position = Vector3.new(mouse.hit.x,mouse.hit.y,mouse.hit.z)
            damage.Parent = workspace
            Thunder.Position = Vector3.new(mouse.hit.x,mouse.hit.y,mouse.hit.z)
            Thunder.Parent = workspace
            wait(1)
            damage:Destroy()
            Thunder:Destroy()
                    else
            print("FAIL THUNDERBOLT")
    end


        end
    end
end

game:GetService("ContextActionService"):BindAction(
    "keyPress", 
    onKeyPress, 
    false, 
    Enum.KeyCode.Q,
    Enum.KeyCode.E,
    Enum.KeyCode.F,
    Enum.KeyCode.T
)

I have a very basic script which raises a player above the ground. The script is player.Character.Humanoid.HipHeight = 15. When the game runs, it works for some players and not for others (the others stay on the game surface). I added a line to the script to confirm the hip height of each player via: print (player.Character.Humanoid.HipHeight) and for all the players it prints out 15. So why do some players stay on the game surface even when it says their hip height is 15 and other players are raised higher? Would love any ideas / theories. Thank you!

asked Mar 19, 2021 at 1:38

Some players stay on the floor, because of their avatar height, for example, anthro players are taller than normal ones, and different body parts from the catalog can have different heights and thus different hipheights. A solution is to add 15(or any number) to the hipheight, for example: player.Character.Humanoid.HipHeight += 15

answered Mar 19, 2021 at 11:34

3

Hey, so, I basically wanted to make this script where if you touch a part, your skin tone will change to black and your clothes will be removed, alongside this I wanted to also make your health be around like 300 and be slightly faster than normal players.

I know how to do the health and speed part, but not the skin tone and clothes part. Any help would be much appreciated!

How do you change your body color on Roblox?

The following steps will assist you with changing your avatar's skin color through the Roblox website. Navigate to your account's Avatar section on the left of the page. On this page, move your cursor over the Body pull-down menu, and select Skin Tone. From here, tap on a color to change the look of your entire avatar.

How do you put scripts on parts on Roblox?

Inserting a Script If you put a script under a Part, Roblox will run the code in the script when the part is loaded into the game. Hover over the DisappearingPlatform part in the Explorer window and click the + button to insert a new script into the platform.