Player = game.Players.LocalPlayer
animation = script:WaitForChild("Animation")
-- Make variables for services
local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
-- Make variables for player, character, and camera
local player = game.Players.LocalPlayer
while not player.Character do wait() end
local character = player.Character
local camera = game.Workspace.CurrentCamera
-- Update camera rotation every render frame
local currentAngle = 0
local deltaAngle = 0
runService.RenderStepped:connect(function()
currentAngle = currentAngle + deltaAngle
camera.CoordinateFrame = CFrame.new(character.Head.Position)
* CFrame.Angles(0, math.rad(currentAngle), 0)
* CFrame.new(0, 0, 10)
end)
-- Check for change event in input. Used for thumbstick input as those are analog
userInputService.InputChanged:connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
-- Check left thumbstick and move character on change
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
character.Humanoid:Move(Vector3.new(input.Position.X, 0, -input.Position.Y), true)
end
-- Check right thumbstick and change camera angle on change
if input.KeyCode == Enum.KeyCode.Thumbstick2 then
deltaAngle = input.Position.X * 5
end
end
end)
-- Check for user input ended events. Handles release of R1 and thumbsticks
userInputService.InputEnded:connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
-- Stop moving character if left thumbstick released
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
character.Humanoid:Move(Vector3.new(0,0,0))
end
-- Stop moving camera if right thumbstick released
if input.KeyCode == Enum.KeyCode.Thumbstick2 then
deltaAngle = 0
end
-- Make character move at normal speed if R1 is released
if input.KeyCode == Enum.KeyCode.ButtonR1 then
character.Humanoid.WalkSpeed = 16
end
end
end)
-- Check for user input began events. Handles jumping and increasing speed
userInputService.InputBegan:connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
-- If A button is pressed then make the character jump
if input.KeyCode == Enum.KeyCode.ButtonA then
character.Humanoid.Jump = true
end
-- If R1 is pressed then make the character move faster
if input.KeyCode == Enum.KeyCode.ButtonR1 then
character.Humanoid.WalkSpeed = 100
end
if input.KeyCode == Enum.KeyCode.ButtonX then
local animationTrack = Player.Character.Humanoid:LoadAnimation(animation)
animationTrack:Play()
wait(1)
animationTrack:Stop()
end
end
end)
Obviously this is an edit of the xbox controller code, I'm just making it do different things. I wanna know is how to make it to where when someone presses x multiple times it well, 50/50 chance of it being 1 out of two animations.

7 comments
use the math.random in cases like this.
....That simple? Wow I should now this stuff man.
How would I implement math.random in this situation?
the way you have your script made, makes it hard to explain.
Mind talking to me on roblox about it?
can't party you :l
Should be able to now