How do you change the body color of a player, with a local script?
Asked by
6 years ago Edited 6 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:
01 | local player = game.Players.LocalPlayer |
02 | local character = player.CharacterAdded:Wait() |
03 | local head = character:WaitForChild( "Head" ) |
05 | local Humanoid = character:WaitForChild( "Humanoid" ) |
06 | local torso = character.UpperTorso |
07 | local mouse = player:GetMouse() |
09 | local bodycolors = character:WaitForChild( "Body Colors" ) |
12 | local Workspace = game.Workspace |
19 | local God = player.PlayerGui.ChooseCharacter.God |
22 | local function onKeyPress(actionName, userInputState, inputObject) |
24 | if userInputState = = Enum.UserInputState.Begin then |
25 | if inputObject.KeyCode.Name = = "T" then |
26 | if God.Value = = "Zeus" then |
27 | game:GetService( "Chat" ):Chat(player.Character.Head, "MASTERBOLT!" , "Blue" ) |
28 | local tool = game.Workspace.BetaBolt:Clone() |
29 | character.Humanoid:EquipTool(tool) |
38 | if inputObject.KeyCode.Name = = "F" then |
39 | if God.Value = = "Zeus" then |
40 | game:GetService( "Chat" ):Chat(player.Character.Head, "FEEL THE POWER OF A TRUE GOD!" , "Blue" ) |
41 | Humanoid.HipHeight = 20 |
42 | bodycolors.RightArmColor = ( "Dark blue" ) |
47 | Humanoid.HipHeight = 1.35 |
51 | if inputObject.KeyCode.Name = = "Q" then |
52 | if God.Value = = "Zeus" then |
53 | game:GetService( "Chat" ):Chat(player.Character.Head, "LIGHTNING DASH!" , "Blue" ) |
54 | head.CFrame = head.CFrame * CFrame.new( 0 , 0 ,- 50 ) |
56 | print ( "FAIL LIGHTNING DASH" ) |
62 | if inputObject.KeyCode.Name = = "E" then |
63 | if God.Value = = "Zeus" then |
64 | game:GetService( "Chat" ):Chat(player.Character.Head, "THUNDER!" , "Blue" ) |
65 | local damage = game.Workspace.Damage:Clone() |
66 | local Thunder = Instance.new( "Part" ) |
67 | Thunder.Name = ( "ThunderBolt" ) |
68 | local mesh = Instance.new( "SpecialMesh" ,Thunder) |
71 | Thunder.Anchored = true |
72 | Thunder.Orientation = Vector 3. new( 0 , 0 , 0 ) |
73 | mesh.Scale = Vector 3. new( 5 , 20 , 15 ) |
74 | damage.Position = Vector 3. new(mouse.hit.x,mouse.hit.y,mouse.hit.z) |
75 | damage.Parent = workspace |
76 | Thunder.Position = Vector 3. new(mouse.hit.x,mouse.hit.y,mouse.hit.z) |
77 | Thunder.Parent = workspace |
82 | print ( "FAIL THUNDERBOLT" ) |
90 | game:GetService( "ContextActionService" ):BindAction( |