game.Players.LocalPlayer.CharacterAdded:Wait() Player = game:GetService('Players') local Character = Player.LocalPlayer.Character local Humanoid = Character.Humanoid local ContextActionService = game:GetService('ContextActionService') local function OnKeyPress() game.Workspace.Part.BrickColor = BrickColor.Random() end ContextActionService:BindAction("PlayAttac", OnKeyPress, true, 'F')
game.Players.LocalPlayer.CharacterAdded:Wait() Player = game:GetService('Players') local Character = Player.LocalPlayer.Character local Humanoid = Character.Humanoid local ContextActionService = game:GetService('ContextActionService') local function OnKeyPress() game.Workspace.Part.BrickColor = BrickColor.new(math.random(0,255),math.random(0,255),math.random(0,255)) end ContextActionService:BindAction("PlayAttac", OnKeyPress, true, Enum.KeyCode.F)
Use math.random()
for the random color and Enum.KeyCode
for keys.