0% found this document useful (0 votes)
14 views3 pages

Script en StarterPlayer Starter

The script manages player interactions in a game, including normal attacks, special abilities, and blocking actions with cooldowns. It creates a health bar and buttons for attacking and blocking, updating the player's health and combo count accordingly. The script ensures that players can only perform actions after specified cooldown periods and updates the UI to reflect the current state of the player.

Uploaded by

Marlene Rivera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

Script en StarterPlayer Starter

The script manages player interactions in a game, including normal attacks, special abilities, and blocking actions with cooldowns. It creates a health bar and buttons for attacking and blocking, updating the player's health and combo count accordingly. The script ensures that players can only perform actions after specified cooldown periods and updates the UI to reflect the current state of the player.

Uploaded by

Marlene Rivera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

-- Script en StarterPlayer > StarterPlayerScripts

local Players = game:GetService("Players")


local TweenService = game:GetService("TweenService")

local normalAttackCooldown = 1 -- Tiempo de reutilización para el ataque normal


local abilityCooldown = 10 -- Tiempo de reutilización para la habilidad especial
local comboResetTime = 2 -- Tiempo en segundos para reiniciar el contador de combos
local blockCooldown = 5 -- Tiempo de reutilización para bloquear
local lastNormalAttackTime = {}
local lastAbilityTime = {}
local lastComboTime = {}
local lastBlockTime = {}

local comboCount = 0
local isBlocking = false

local function setupPlayer(player)


local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")

local health = 100


local maxHealth = 100

local healthBar = Instance.new("BillboardGui")


healthBar.Adornee = rootPart
healthBar.Size = UDim2.new(2, 0, 0.2, 0)
healthBar.StudsOffset = Vector3.new(0, 3, 0)

local healthFrame = Instance.new("Frame")


healthFrame.Size = UDim2.new(1, 0, 1, 0)
healthFrame.BackgroundColor3 = Color3.new(1, 0, 0)
healthFrame.BorderSizePixel = 0
healthFrame.Parent = healthBar

healthBar.Parent = player.PlayerGui

local abilityButton = Instance.new("TextButton")


abilityButton.Size = UDim2.new(0.2, 0, 0.1, 0)
abilityButton.Position = UDim2.new(0.4, 0, 0.8, 0)
abilityButton.BackgroundColor3 = Color3.new(0, 0, 1)
abilityButton.BorderSizePixel = 0
abilityButton.Text = "Attack"
abilityButton.TextColor3 = Color3.new(1, 1, 1)
abilityButton.Parent = player.PlayerGui

local blockButton = Instance.new("TextButton")


blockButton.Size = UDim2.new(0.2, 0, 0.1, 0)
blockButton.Position = UDim2.new(0.7, 0, 0.8, 0)
blockButton.BackgroundColor3 = Color3.new(0, 1, 0)
blockButton.BorderSizePixel = 0
blockButton.Text = "Block"
blockButton.TextColor3 = Color3.new(1, 1, 1)
blockButton.Parent = player.PlayerGui

local comboText = Instance.new("TextLabel")


comboText.Size = UDim2.new(0.2, 0, 0.1, 0)
comboText.Position = UDim2.new(0.6, 0, 0.8, 0)
comboText.BackgroundColor3 = Color3.new(1, 1, 1)
comboText.BorderSizePixel = 0
comboText.Text = "Combos: 0"
comboText.TextColor3 = Color3.new(0, 0, 0)
comboText.Parent = player.PlayerGui

local function onAbilityClick()


local currentTime = tick()
if not lastAbilityTime[player.UserId] or (currentTime -
lastAbilityTime[player.UserId] >= abilityCooldown) then
if humanoid.Health > 0 then
humanoid.Health = humanoid.Health - 20 -- Daño mayor para la
habilidad
updateHealthBar()
lastAbilityTime[player.UserId] = currentTime
updateCombo()
end
end
end

abilityButton.MouseButton1Down:Connect(onAbilityClick)

local function onPlayerClick()


local currentTime = tick()
if not lastNormalAttackTime[player.UserId] or (currentTime -
lastNormalAttackTime[player.UserId] >= normalAttackCooldown) then
if humanoid.Health > 0 and not isBlocking then
humanoid.Health = humanoid.Health - 10 -- Ajusta el valor de
acuerdo a tus necesidades
updateHealthBar()
lastNormalAttackTime[player.UserId] = currentTime
updateCombo()
end
end
end

player:GetMouse().Button1Down:Connect(onPlayerClick)

local function onBlockClick()


local currentTime = tick()
if not lastBlockTime[player.UserId] or (currentTime -
lastBlockTime[player.UserId] >= blockCooldown) then
isBlocking = not isBlocking
lastBlockTime[player.UserId] = currentTime
end
end

blockButton.MouseButton1Down:Connect(onBlockClick)

local function updateHealthBar()


local percent = humanoid.Health / maxHealth
local targetSize = UDim2.new(percent, 0, 1, 0)

local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad,


Enum.EasingDirection.Out)
local tween = TweenService:Create(healthFrame, tweenInfo, {Size =
targetSize})

tween:Play()
end

local function updateCombo()


local currentTime = tick()
if not lastComboTime[player.UserId] or (currentTime -
lastComboTime[player.UserId] >= comboResetTime) then
comboCount = 1
else
comboCount = comboCount + 1
end

lastComboTime[player.UserId] = currentTime
comboText.Text = "Combos: " .. comboCount
end

humanoid.HealthChanged:Connect(updateHealthBar)
end

Players.PlayerAdded:Connect(setupPlayer)

You might also like