I'd like to know if there is a way to reset a script because I made an ability script that gives you an ability depending on which one you choose, but when you die, it only activates your previous ability. If there is a way to reset a script then I would like to know! If there is another way, here are two scripts (both of which are localscripts and I am not changing that):
local pow = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("PowerGui2"):WaitForChild("Frame")
local ability = pow.Power
local plr = game.Players.LocalPlayer.Character
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.Q and ability.Value == 1 then
game.ReplicatedStorage.Speedparticle:Clone().Parent = game.Players.LocalPlayer.Character:FindFirstChild("UpperTorso")
game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 40
wait(10)
game.Players.LocalPlayer.Character:FindFirstChild("UpperTorso").Speedparticle:Remove()
game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 16
end
local RS = game:GetService("ReplicatedStorage")
local remoteEvent = RS:WaitForChild("RemoteEvent")
UIS.InputBegan:Connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.Q and ability.Value ==2 then
remoteEvent:FireServer() --Nothing passed to the server
wait(0.5)
for i, Child in pairs(plr:getChildren()) do
if Child:IsA('Part') or Child:IsA('MeshPart') or Child:IsA('Accessory') then
Child.Transparency = 0.5
end
end
plr:FindFirstChild("Head").face.Transparency = 0.5
plr:FindFirstChild("HumanoidRootPart").Transparency = 1
wait(9.5)
for i, Child in pairs(plr:getChildren()) do
if Child:IsA('Part') or Child:IsA('MeshPart') or Child:IsA('Accessory') then
Child.Transparency = 0
end
end
plr:FindFirstChild("Head").face.Transparency = 0
plr:FindFirstChild("HumanoidRootPart").Transparency = 1
end
end)
UIS.InputBegan:connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.Q and ability.Value == 3 then
game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("beserk").Value = true
for i, tool in pairs(plr:getChildren()) do
if tool:IsA('Tool') then
for i, child in pairs(tool:getChildren()) do
if child.Name == "Blade" then
game.ReplicatedStorage.BeserkParticle:Clone().Parent = child
elseif child.Name == "BeserkScript" then
child.Disabled = false
end
end
end
end
plr.Humanoid.WalkSpeed = 25
wait(10)
plr.Humanoid.WalkSpeed = 16
for i, tool in pairs(plr:getChildren()) do
if tool:IsA('Tool') then
for i, child in pairs(tool:getChildren()) do
if child.Name == "Blade" then
for i, particle in pairs(child:getChildren()) do
if particle:IsA('ParticleEmitter') then
particle:Remove()
end
end
end
end
end
end
game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("beserk").Value = false
end
end)
local remoteEvent2 = RS.RemoteEvent2
UIS.InputBegan:connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.Q and ability.Value == 4 then
remoteEvent2:FireServer()
end
end)
end)
The script below is the script that applies your choice
local pow = game.Players.LocalPlayer.PlayerGui.PowerGui2.Frame.Power
script.Parent.Select1.MouseButton1Click:Connect(function()
local gui = game.Players.LocalPlayer.PlayerGui.PowerGui2.Frame
gui.Select1.Text = "Selected"
gui.Select2.Text = "Select"
gui.Select3.Text = "Select"
gui.Select4.Text = "Select"
pow.Value = 1
end)
script.Parent.Select2.MouseButton1Click:Connect(function()
local gui = game.Players.LocalPlayer.PlayerGui.PowerGui2.Frame
gui.Select1.Text = "Select"
gui.Select2.Text = "Selected"
gui.Select3.Text = "Select"
gui.Select4.Text = "Select"
pow.Value = 2
end)
script.Parent.Select3.MouseButton1Click:Connect(function()
local gui = game.Players.LocalPlayer.PlayerGui.PowerGui2.Frame
gui.Select1.Text = "Select"
gui.Select2.Text = "Select"
gui.Select3.Text = "Selected"
gui.Select4.Text = "Select"
pow.Value = 3
end)
script.Parent.Select4.MouseButton1Click:Connect(function()
local gui = game.Players.LocalPlayer.PlayerGui.PowerGui2.Frame
gui.Select1.Text = "Select"
gui.Select2.Text = "Select"
gui.Select3.Text = "Select"
gui.Select4.Text = "Selected"
pow.Value = 4
end)

3 comments
I don't exactly know how to reset values though...
Let me further add to my answer then, thank you for clarifying :)
I added a wait(6) before all of that stuff happpened