I recently designed a new feature for my game, which randomly chooses a random property within the humanoid (JumpPower or walkspeed) to increase by a random amount. However, it doesn’t appear to be working. There are no errors, it just keeps the text label’s text at nil. I have no idea why this is happening. I feel like it may be linked to my round system, so I’ve provided part of the round system script, where the event related to this local script is being fired.
if inter.Value == 0 then
game.ReplicatedStorage.IsIntermission.Value = false
TeleportPlayers()
TagAllPlayers("Alive")
game.ServerStorage.DisasterEvent:Fire(numberOfDisasters, true)
game.ReplicatedStorage.StartPowerups:FireAllClients(true)
for i = 120, 0, -1 do
roundtime.Value = i
game.ServerStorage.PlayerEliminated.Event:Connect(function(plr)
collectionService:RemoveTag(plr, "Alive")
collectionService:AddTag(plr, "Dead")
plr.CRW.Value = false
end)
wait(1)
end
if roundtime.Value == 0 then
game.ReplicatedStorage.StartPowerups:FireAllClients(false)
TeleportPlayersBackToLobby()
wait(1)
AwardPlayers()
wait(1)
CleanUp()
end
end
The actual local script code itself is this:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local CollectionService = game:GetService("CollectionService")
local Choices = {"R", "J"}
local ShouldStart = false
game.ReplicatedStorage.StartPowerups.OnClientEvent:Connect(function(bool)
ShouldStart = bool
if bool then
local Valid = true
wait(2)
for i, v in pairs(CollectionService:GetTagged("Dead")) do
if v == Player then
Valid = false
end
end
while wait(10) do
if Valid then
if ShouldStart then
local ShouldAdd = math.random(1, 7)
local rndm = Choices[math.random(1,#Choices)]
if rndm == "R" then
script.Parent.Image.TextLabel.Text = "+"..tostring(ShouldAdd).." Speed"
Humanoid.WalkSpeed = 16 + ShouldAdd
else
script.Parent.Image.TextLabel.Text = "+"..tostring(ShouldAdd).." Jump Power"
Humanoid.JumpPower = 50 + ShouldAdd
end
else
break
end
else
print("Player not valid")
script.Parent.Image.TextLabel.Text = nil
end
end
else
script.Parent.Image.TextLabel.Text = nil
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)
Help very much appreciated
Thanks in advance!