01 | game.Players.LocalPlayer.CharacterAdded:Wait() |
02 |
03 | Player = game:GetService( 'Players' ) |
04 |
05 | local Character = Player.LocalPlayer.Character |
06 | local Humanoid = Character.Humanoid |
07 | local ContextActionService = game:GetService( 'ContextActionService' ) |
08 |
09 | local function OnKeyPress() |
10 | game.Workspace.Part.BrickColor = BrickColor.Random() |
11 | end |
12 |
13 | ContextActionService:BindAction( "PlayAttac" , OnKeyPress, true , 'F' ) |
01 | game.Players.LocalPlayer.CharacterAdded:Wait() |
02 |
03 | Player = game:GetService( 'Players' ) |
04 |
05 | local Character = Player.LocalPlayer.Character |
06 | local Humanoid = Character.Humanoid |
07 | local ContextActionService = game:GetService( 'ContextActionService' ) |
08 |
09 | local function OnKeyPress() |
10 | game.Workspace.Part.BrickColor = BrickColor.new(math.random( 0 , 255 ),math.random( 0 , 255 ),math.random( 0 , 255 )) |
11 | end |
12 |
13 | ContextActionService:BindAction( "PlayAttac" , OnKeyPress, true , Enum.KeyCode.F) |
Use math.random()
for the random color and Enum.KeyCode
for keys.