Hey,
so Iv’e developed a game with boosts, 2 in particular are jumppower and walkspeed boosts. Whenever a player enables it, I scripted it to work but, if they die, I wanted the boost to be activated still when they respawn.
I tried in a script, trying to give the player their current walkspeed/jumppower boost whenever their character is added, also using RemoteEvents.
Gui button for boost.
Local Script:
local buy = script.Parent
local Enable = “Enable”
local Disable = “Disable”
local function Boost()
if buy.Text == Enable then
buy.BackgroundColor3 = Color3.new(255,85,0)
buy.Text = Disable
game.ReplicatedStorage.WalkspeedAndJumppower.Walkspeed1:FireServer()
elseif buy.Text == Disable then
buy.BackgroundColor3 = Color3.new(0,255,0)
buy.Text = Enable
game.ReplicatedStorage.WalkspeedAndJumppower.NoWalkspeed1:FireServer()
end
end
buy.MouseButton1Click:Connect(Boost)
game.Players.LocalPlayer.CharacterAdded:Connect(function()
if script.Parent.Text == Disable then
game.ReplicatedStorage.WalkspeedAndJumppower.Walkspeed1:FireServer()
end
end)
I put this script in StarterCharacterScripts and did script.parent.Humanoid to reference a player’s humanoid, doing it any other way just didn’t work.
Script:
local function Walkspeed1()
script.Parent.Humanoid.WalkSpeed = script.Parent.Humanoid.WalkSpeed +10
end
game.ReplicatedStorage.WalkspeedAndJumppower.Walkspeed1:OnServerEvent:Connect(Walkspeed1)
It works but, it affects all Players, I don’t know how make it so that it affects the player activating the boost.