I'm having trouble with the math.random() it keeps doing one thing only, And its not randomizing the combat at all. I cant find the error and i've looked through it 5 times now, Can anyone help?
player = game.Players.LocalPlayer.Character
cooldown = 1 --Put amount of seconds for cooldown to last.
db = false
Combat = math.random(1,2)
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
if db == false then
db = true
--your code
if Combat == 1 then
print("Loading First Punch")
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=906039050"
local animTrack = player.Humanoid:LoadAnimation(animation)
animTrack:Play()
wait(cooldown)
db = false
end
if Combat == 2 then
print("Loading Second Punch")
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=913285256"
local animTrack = player.Humanoid:LoadAnimation(animation)
animTrack:Play()
wait(cooldown)
db = false
end
end
end
end
game.ContextActionService:BindAction("keyPress", onKeyPress, false, "r")
****Thank you for the help :D
