Hello! The past few days a few of you have helped me finish a project I never thought would be this hard, but this probably is the last time I post about this. This is sort of big, so make sure you read everything before making a judgement etc.
The hold-e-to-fix-local-script-o
Independent (Nothing else is in the script excluding given code) = true
local UserInputService = game:GetService("UserInputService")
local HoldTime = 0
local Holding = false
local Red = 0
local Green = 0
local Blue = 0
local DB = false
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if (game.Players.LocalPlayer:GetAttribute("CanRestorePower") == true and DB == false and workspace.Power.Button:GetAttribute("CanReStore") == true) then
DB = true
game.ReplicatedStorage.PowerOccupied:FireServer(game.Players.LocalPlayer, true)
HoldTime = tick()
Holding = true
workspace.Power.Sounds.PowerUP:Play()
local UiSize = 0
while Holding == true do
workspace.Power.Button.Color = Color3.fromRGB(0, Green, 0)
game.Players.LocalPlayer.PlayerGui.PowerGui.Restoring.Visible = true
UiSize = UiSize + 4.5
local TweenGuiSize = game.Players.LocalPlayer.PlayerGui.PowerGui.Restoring.Bar:TweenSize(
UDim2.new(0, UiSize, 0, 25),
Enum.EasingDirection.Out,
Enum.EasingStyle.Linear,
0.1,
true
)
game.Players.LocalPlayer.PlayerGui.PowerGui.Restoring.Bar.Size = UDim2.new(0, UiSize, 0, 25)
if Green == 75 then
workspace.Power.Sounds.PowerUP:Stop()
workspace.Power.Sounds.PowerUP2:Play()
end
if Green == 100 then
Green = 0
workspace.Power.Button.Color = Color3.new(0,1,0)
game.ReplicatedStorage.RestorePower:FireServer(game.Players.LocalPlayer)
game.Players.LocalPlayer.PlayerGui.PointsGui.PointsGained.Text = "Gained 50 Points!"
game.Players.LocalPlayer.PlayerGui.PointsGui.PointsGained.Visible = true
workspace.Power.Sounds.PowerUP:Stop()
workspace.Power.Sounds.PowerUP2:Stop()
task.wait(1)
game.Players.LocalPlayer.PlayerGui.PowerGui.Restoring.Visible = false
task.wait(2)
game.Players.LocalPlayer.PlayerGui.PointsGui.PointsGained.Visible = false
game.Players.LocalPlayer.PlayerGui.PointsGui.PointsGained.Text = "Gained (Points)"
warn("Ending")
Holding = false
end
warn("Didn't end")
Green += 1
task.wait(0.1)
end
end
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if game.Players.LocalPlayer:GetAttribute("CanRestorePower") == true then
Holding = false
workspace.Power.Button.Color = Color3.new(0,0,0)
Green = 0
local GreenTransformation = workspace.Power.Button.Color.G * 255
local TweenGuiSize = game.Players.LocalPlayer.PlayerGui.PowerGui.Restoring.Bar:TweenSize(
UDim2.new(0, 0, 0, 25),
Enum.EasingDirection.Out,
Enum.EasingStyle.Linear,
0.5,
true
)
if GreenTransformation >= 100 then
game.ReplicatedStorage.RestorePower:FireServer()
end
workspace.Power.Sounds.PowerUP:Stop()
workspace.Power.Sounds.PowerUP2:Stop()
task.wait(3)
DB = false
end
end
end)
The restore-current-power-scrip-to
Independent (Nothing else is in the script excluding given code) = true
game.ReplicatedStorage.RestorePower.OnServerEvent:Connect(function(playerWhoEnabled)
for index, value in pairs(game.Players:GetPlayers()) do
local CharacterEnsure = value.Character or value.CharacterAdded:Wait()
local Character = value.Character
Character:WaitForChild("ShowPowerStationRestore").Disabled = true
end
game.ServerScriptService.Power.PowerRemoving.Disabled = false
game.ServerStorage.Power.Gui.PersonWhoRestored.Value = playerWhoEnabled
game.ServerStorage.Power.Gui.CanMessageOn.Value = true
game.ServerStorage.Power.Gui.CanMessageOn.Value = true
game:GetService("ServerStorage").Power.PowerOn.Value = true
workspace.Power.Button.BillboardGui.Enabled = false
playerWhoEnabled.leaderstats.Points.Value += 50
game.ServerStorage.Power.CurrentPower.Value = game.ServerStorage.Power.MaxPower.Value
print(game.ServerStorage.Power.CurrentPower.Value)
workspace.Power.Button.BillboardGui.Enabled = false
workspace.Power.Shock.DamageScript.Disabled = false
workspace.Power.Shock.Transparency = 0.7
workspace.Power.Shock.CanCollide = true
task.wait(0.5)
print(game.ServerStorage.Power.CurrentPower.Value)
end)
Thanks a lot everyone. I've been trying my hardest the past few days about this and I am still learning. Thanks for helping!