Mad Bloxxer Haste power not working!

Hello!

So i followed the Mad Bloxxer tutorial via YouTube. And i decided to make the speed boost seperate. (I mean by having the need to buy it to get a speed boost)

I’ve wrote the code neccesary for making the power work. But nothing happens. No points reduced and no haste.

I tried searching around the DevForum but no result.

I will like every attempt on fixing the coding! And you can also reply with spelling mistakes i made and i will fix the mistakes! By the way here’s everything i coded:

local powerslabel = gui:WaitForChild("Haste")
local powersbutton = powerslabel:WaitForChild("Button")
local powerswindow = gui:WaitForChild("HasteWindow")

local powersclose = powerswindow:WaitForChild("XButton")
local powershastebuy = powerswindow:WaitForChild("BuyButton")

-- Gets the GUIs from the ScreenGui. Now the code that fires a RemoteEvent to the server.

powershastebuy.MouseButton1Down:connect(function()
	event:FireServer("Buy", "Haste")
end)

-- Now to the Server script. (Sperate from this lua brick lol)
local haste = Instance.new("IntValue")
	haste.Name = "HasHaste"
	haste.Value = mydata.hashaste
	haste.Parent = player

-- Inserts a IntValue in the player's stuff i don't know. Now to the code that manages the event.

elseif tuple[2] == "Haste" then
				local mydata = playerdata[player.userId]
				if mydata and mydata.points >= 250 and mydata.hashaste == 0 then
					mydata.hashaste = 1

					awardpoints(player, -250)
					local hashastevalue = player:FindFirstChild("HasHaste")
					if hashastevalue then
						hashastevalue.Value = mydata.hashaste
					end
-- elseif Is used becuase there are more things. For example every purchase from points, bloxxer multiplier and haste is all in control with a RemoteEvent.

-- The thing is nothing happens when i click on the Buy for 250 Points button.
1 Like

Try printing mydata.points and mydata.hashaste.

1 Like

I will right now. But printing the points is useless becuase i have it as a GUI on my screen.

@PerilousPanther Here’s the code:

elseif tuple[2] == "Haste" then
				local mydata = playerdata[player.userId]
				if mydata and mydata.points >= 250 and mydata.hashaste == 0 then
					mydata.hashaste = 1
					print(mydata.hashaste)
					print(mydata.points)

					awardpoints(player, -250)
					local hashastevalue = player:FindFirstChild("HasHaste")
					if hashastevalue then
						hashastevalue.Value = mydata.hashaste
					end

But the output doesn’t have anything. :frowning:

1 Like

Try printing what tuple[2] is supposed to be when you first fire the OnServerEvent?

It doesn’t print anything. But here’s the code to make sure i did not make print not working.

elseif tuple[2] == "Haste" then
				local mydata = playerdata[player.userId]
				if mydata and mydata.points >= 250 and mydata.hashaste == 0 then
					mydata.hashaste = 1
					print(mydata.hashaste)
					print(mydata.points)
					print(tuple[2])

					awardpoints(player, -250)
					local hashastevalue = player:FindFirstChild("HasHaste")
					if hashastevalue then
						hashastevalue.Value = mydata.hashaste
					end

Do:

powershastebuy.MouseButton1Down:connect(function()
    print("Haste")
	event:FireServer("Buy", "Haste")
end)

In the LocalScript? (Like if yes)

1 Like

I meant don’t put it inside the if statement, but rather print it when you first fire your OnServerEvent function

It won’t print anything if you place it inside there, and check that it’s equal to “Haste”, so you have to reference it the moment you first call OnServerEvent

1 Like

This is what it printed: 16:33:39.992 Haste - Client - LocalGuiScript:180

I can’t do that in the function becuase it’s seperate from the Script. Here’s what it printed:

16:36:15.336 Haste - Client - LocalGuiScript:180 16:36:15.336 Players.thatrandomnoob23.PlayerGui.ScreenGui.LocalGuiScript:181: attempt to index nil with 'hashaste' - Client - LocalGuiScript:181 16:36:15.336 Stack Begin - Studio 16:36:15.336 Script 'Players.thatrandomnoob23.PlayerGui.ScreenGui.LocalGuiScript', Line 181 - Studio - LocalGuiScript:181 16:36:15.337 Stack End - Studio

WAIT A BIT DON’T REPLY

Could you paste the entire server script?





local roundtime = 60 * 5
local intermissiontime = 20


local marketservice = game:GetService("MarketplaceService")
local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerData")
local serverstorage = game:GetService("ServerStorage")
local replicatedstorage = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")
local event = replicatedstorage:WaitForChild("RemoteEvent")
local maps = serverstorage:WaitForChild("Maps")
local mapholder = game.Workspace:WaitForChild("MapHolder")
local statustag = replicatedstorage:WaitForChild("StatusTag")
local timertag = replicatedstorage:WaitForChild("TimerTag")

local playerdata = {}

-- Set up score leaderboard
	-- Keep track of points
		-- Drop sheriff net gun if bloxxed
		-- Make sure sheriff doesn't blox bystanders




function awardwin(player)
	if player  then
		local mydata = playerdata[player.userId]
		local leaderstats = player:FindFirstChild("leaderstats")
		if leaderstats and mydata then
			mydata.wins = mydata.wins + 1
			local winsvalue = leaderstats:FindFirstChild("Wins")
			if winsvalue then
				winsvalue.Value = mydata.wins
			end
		end
	end
end

function awardpoints(player, points)
	if player and points then
		local mydata = playerdata[player.userId]
		if mydata then
			mydata.points = mydata.points + points
			local pointsvalue = player:FindFirstChild("Points")
			if pointsvalue then
				pointsvalue.Value = mydata.points
			end
		end
	end
end

function dropnetgun(pos)
	local pickup = serverstorage:WaitForChild("Net Gun"):WaitForChild("Handle"):clone()
	pickup.Name = "Pickup"
	pickup.Anchored = true
	pickup.CanCollide = false
	pickup.CFrame = CFrame.new(pos)

	local sparkles = Instance.new("Sparkles")
	sparkles.SparkleColor = Color3.new(0, .5, 1)
	sparkles.Parent = pickup

	local given = false
	pickup.Touched:connect(function(hit)
		local humanoid = hit.Parent:FindFirstChild("Humanoid")
		if humanoid and humanoid.Health > 0 then
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			if player and player ~= bloxxer then
				local backpack = player:FindFirstChild("Backpack")
				if backpack and not given then
					given = true
					pickup:remove()
					local netgun = serverstorage:WaitForChild("Net Gun"):clone()
					netgun.Parent = backpack
					sheriff = player
				end
			end
		end
	end)
	for _, player in pairs(game.Players:GetChildren()) do
		if player and player.Character and player.Character.Parent then
			local humanoid = player.Character:FindFirstChild("Humanoid")
			if humanoid and humanoid.WalkSpeed < 16 then
				humanoid.WalkSpeed = 16
			end
		end
	end

	debris:AddItem(pickup,roundtime)
	pickup.Parent=game.Workspace
end

function newcharacter(bloxxedplayer, character)
	local humanoid = character:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.Died:connect(function()
			
			if bloxxedplayer == sheriff then
				humanoid:UnequipTools()
				local backpack = bloxxedplayer:FindFirstChild("Backpack")
				if backpack then
					backpack:ClearAllChildren()
				end
				local torso = character:FindFirstChild("Torso")
				if torso then
					dropnetgun(torso.Position)
				end
			end

			local tag = humanoid:FindFirstChild("creator")
			if tag and tag.Value and tag.Value.Parent == game.Players then
				if tag.Value ~= bloxxer and bloxxedplayer ~= bloxxer then
					local wrongdoer = tag.Value
					if wrongdoer.Character and wrongdoer.Character.Parent then
						local wrongdoerhumanoid = wrongdoer.Character:FindFirstChild("Humanoid")
						if wrongdoerhumanoid then
							wrongdoerhumanoid.Health = 0
						end
					end
				end
			end

		end)
	end
end

function playeradded(player)
	local leaderstats = Instance.new("IntValue")
	leaderstats.Name = "leaderstats"

	local mydata = datastore:GetAsync(player.userId) or {}
	mydata.points = mydata.points or 0
	mydata.wins = mydata.wins or 0
	mydata.multiplier = mydata.multiplier or 1
	mydata.emeraldsword = mydata.emeraldsword or 0

	playerdata[player.userId] = mydata
	
	local wins = Instance.new("IntValue")
	wins.Name = "Wins"
	wins.Value = mydata.wins
	wins.Parent = leaderstats

	local points = Instance.new("IntValue")
	points.Name = "Points"
	points.Value = mydata.points
	points.Parent = player

	local multiplier = Instance.new("IntValue")
	multiplier.Name = "Multiplier"
	multiplier.Value = mydata.multiplier
	multiplier.Parent = player

	local emeraldsword = Instance.new("IntValue")
	emeraldsword.Name = "EmeraldSword"
	emeraldsword.Value = mydata.emeraldsword
	emeraldsword.Parent = player
	
	local haste = Instance.new("IntValue")
	haste.Name = "HasHaste"
	haste.Value = mydata.hashaste
	haste.Parent = player
	
	leaderstats.Parent = player

	player.CharacterAdded:connect(function(character)
		newcharacter(player, character)
	end)
	if player.Character and player.Character.Parent then
		newcharacter(player, player.Character)
	end
end
game.Players.PlayerAdded:connect(playeradded)
for _, player in pairs(game.Players:GetPlayers()) do
	playeradded(player)
end

function permanentsave(player)
	if player then
		local mydata = playerdata[player.userId]
		if mydata then
			datastore:SetAsync(player.userId, mydata)
		end
	end
end

game.Players.PlayerRemoving:connect(function(player)
	if player then
		permanentsave(player)
		playerdata[player.userId] = nil
	end
end)

game.OnClose = function()
	for i, v in pairs(playerdata) do
		datastore:SetAsync(i, v)
	end
end


function findplayerbyid(userid)
	for _, player in pairs(game.Players:GetPlayers()) do
		if player and player.userId == userid then
			return player
		end
	end
end

function productpurchased(userid,productid,ispurchased,isapppurchase)
	if ispurchased then
		local player = findplayerbyid(userid)
		if player then
			if productid == 1169828694 then
				awardpoints(player,100)
			end
		end
	end
end
marketservice.PromptProductPurchaseFinished:connect(productpurchased)


event.OnServerEvent:connect(function(player, ...)
	if player then
		local tuple = {...}
		if tuple[1] == "Buy" then
			if tuple[2] == "100Points" then
				marketservice:PromptProductPurchase(player,1169828694,false,Enum.CurrencyType.Robux)
			elseif tuple[2] == "BloxxerChance" then
				local mydata = playerdata[player.userId]
				if mydata and mydata.points >= 25 then
					mydata.multiplier = mydata.multiplier + 5
					if mydata.multiplier == 6 then
						mydata.multiplier = 5
					end

					awardpoints(player, -25)
					local multipliervalue = player:FindFirstChild("Multiplier")
					if multipliervalue then
						multipliervalue.Value = mydata.multiplier
					end
				end
			elseif tuple[2] == "EmeraldSword" then
				local mydata = playerdata[player.userId]
				if mydata and mydata.points >= 100 and mydata.emeraldsword == 0 then
					mydata.emeraldsword = 1

					awardpoints(player, -100)
					local emeraldswordvalue = player:FindFirstChild("EmeraldSword")
					if emeraldswordvalue then
						emeraldswordvalue.Value = mydata.emeraldsword
					end
				end
			elseif tuple[2] == "Haste" then
				local mydata = playerdata[player.userId]
				print(mydata.hashaste)
				print(mydata.points)
				print(tuple[2])
				if mydata and mydata.points >= 250 and mydata.hashaste == 0 then
					mydata.hashaste = 1
					print(mydata.hashaste)
					print(mydata.points)
					print(tuple[2])

					awardpoints(player, -250)
					local hashastevalue = player:FindFirstChild("HasHaste")
					if hashastevalue then
						hashastevalue.Value = mydata.hashaste
					end
				end
			end
		end
	end
end)

while true do
	-- Load a random map
	statustag.Value = "Loading Map"
	timertag.Value = -1
	mapholder:ClearAllChildren()
	wait(2)
	local allmaps = maps:GetChildren()
	local newmap = allmaps[math.random(1, #allmaps)]:clone()
	newmap.Parent = mapholder
	wait(2)

	-- Wait for contestants
	while true do
		wait(5)
		contestants = {}
		for _, player in pairs(game.Players:GetPlayers()) do
			if player and player.Character then
				local humanoid = player.Character:WaitForChild("Humanoid")
				if humanoid and humanoid.Health > 0 then
					table.insert(contestants, player)
				end
			end
		end
		if #contestants >= 2 then
			break
		else
			statustag.Value = "Waiting for Players"
			timertag.Value = -1
		end
	end

	statustag.Value = "Match"
	timertag.Value = roundtime

	-- Choose bloxxer
	local weightedcontestants = {}
	for _, player in pairs(contestants) do
		if player then
			local weight = 1

			local mydata = playerdata[player.userId]
			if mydata and mydata.multiplier then
				weight = mydata.multiplier
			end
			
			for i = 1, weight do
				table.insert(weightedcontestants, player)
			end
		end
	end
	bloxxer = weightedcontestants[math.random(1, #weightedcontestants)]
	local mydata = playerdata[bloxxer.userId]
	if mydata and mydata.multiplier and mydata.multiplier > 1 then
		mydata.multiplier = 1
		local multipliervalue = bloxxer:FindFirstChild("Multiplier")
		if multipliervalue then
			multipliervalue.Value = mydata.multiplier
		end
	end

	-- Choose sheriff
	while true do
		randomplayer = contestants[math.random(1, #contestants)]
		if randomplayer ~= bloxxer then
			sheriff = randomplayer
			break
		end
	end

	-- Teleport contestants
	local spawnsmodel = newmap:WaitForChild("Spawns")
	local spawns = spawnsmodel:GetChildren()
	for _, player in pairs(contestants) do
		if player and player.Character and #spawns > 0 then
			local torso = player.Character:WaitForChild("Torso")
			local humanoid = player.Character:WaitForChild("Humanoid")
			local spawnindex = math.random(1, #spawns)
			local spawn = spawns[spawnindex]
			if spawn and torso and humanoid then
				humanoid.Health = 100
				humanoid.WalkSpeed = 16
				table.remove(spawns, spawnindex)
				torso.CFrame = CFrame.new(spawn.Position + Vector3.new(0, 3, 0))
				
				local matchtag = Instance.new("StringValue")
				matchtag.Name = "MatchTag"
				matchtag.Parent = player.Character

				local backpack = player:FindFirstChild("Backpack")
				if backpack then
					if player == bloxxer then
						local sword = serverstorage:WaitForChild("Sword"):clone()
						sword.Parent = backpack
						event:FireClient(player, "Class", "Bloxxer")

						local mydata = playerdata[player.userId]
						if mydata and mydata.emeraldsword == 1 then
							local emeraldswordvalue = sword:FindFirstChild("EmeraldSword")
							if emeraldswordvalue then
								emeraldswordvalue.Value = true
							end
						end

					elseif player == sheriff then
						local netgun = serverstorage:WaitForChild("Net Gun"):clone()
						netgun.Parent = backpack
						event:FireClient(player, "Class", "Sheriff")
					else
						event:FireClient(player, "Class", "Bystander")
					end
				end
			end
		end
	end
	spawnsmodel:remove()

	-- Wait for round end conditions
	local localtimer = roundtime
	while localtimer > 0 do
		wait(1)
		localtimer = localtimer - 1
		timertag.Value = localtimer

		activecontestants = {}
		bloxxeractive = false
		for _, player in pairs(contestants) do
			if player then
				local character = player.Character
				if character then
					local matchtag = character:FindFirstChild("MatchTag")
					local humanoid = character:FindFirstChild("Humanoid")
					if matchtag and humanoid and humanoid.Health > 0 then
						if player == bloxxer then
							bloxxeractive = true
						end
						table.insert(activecontestants, player)
					end
				end
			end
		end
		if #activecontestants <= 1 or not bloxxeractive then
			break
		end
	end

	-- Sort game result
	local gameresult = "PlayersWin"
	if bloxxeractive then
		if #activecontestants >= 2 then
			event:FireAllClients("Result", "PlayersWin")
		else
			gameresult = "BloxxerWin"
			event:FireAllClients("Result", "BloxxerWin")
		end
	else
		event:FireAllClients("Result", "PlayersWin")
	end
	for _, v in pairs(game.Workspace:GetChildren()) do
		if v then
			if v.Name == "Pickup" or v.className == "Hat" then
				v:remove()
			end
		end
	end
	for _, player in pairs(contestants) do
		if player then
			if gameresult == "BloxxerWin" and player == bloxxer then
				awardwin(player)
				awardpoints(player, 9)
			elseif gameresult ~= "BloxxerWin" and player ~= bloxxer then
				if player == sheriff then
					awardwin(player)
					awardpoints(player, 4)
				else
					awardwin(player)
					awardpoints(player, 2)
				end
			end
		end
	end

	-- Teleport plays back to lobby
	local lobbyspawns = {}
	for _, v in pairs(game.Workspace:WaitForChild("Lobby"):GetChildren()) do
		if v and v.Name == "SpawnLocation" then
			table.insert(lobbyspawns, v)
		end
	end
	for _, player in pairs(activecontestants) do
		if player then
			awardpoints(player, 1)
			if player.Character then
				local humanoid = player.Character:FindFirstChild("Humanoid")
				if humanoid then
					humanoid:UnequipTools()
				end
			end

			local randomspawn = lobbyspawns[math.random(1, #lobbyspawns)]
			player.Character:MoveTo(randomspawn.Position)

			local backpack = player:FindFirstChild("Backpack")
			if backpack then
				backpack:ClearAllChildren()
			end
		end
	end
	bloxxer = nil
	sheriff = nil

	-- Intermission wait
	statustag.Value = "Intermission"
	timertag.Value = intermissiontime
	local localtimer = intermissiontime
	while localtimer > 0 do
		wait(1)
		localtimer = localtimer - 1
		timertag.Value = localtimer
	end
end







Oh sorry but mydata and tuple don’t seem to work over there. So i can’t print. :frowning: Oh and yea that dude with the leaderboard thing is replying

Breaking it down to these lines:

event.OnServerEvent:connect(function(player, ...)
	if player then
		local tuple = {...}
		if tuple[1] == "Buy" then
			if tuple[2] == "100Points" then
				marketservice:PromptProductPurchase(player,1169828694,false,Enum.CurrencyType.Robux)
			elseif tuple[2] == "BloxxerChance" then
				local mydata = playerdata[player.userId]
				if mydata and mydata.points >= 25 then
					mydata.multiplier = mydata.multiplier + 5
					if mydata.multiplier == 6 then
						mydata.multiplier = 5
					end

					awardpoints(player, -25)
					local multipliervalue = player:FindFirstChild("Multiplier")
					if multipliervalue then
						multipliervalue.Value = mydata.multiplier
					end
				end
			elseif tuple[2] == "EmeraldSword" then
				local mydata = playerdata[player.userId]
				if mydata and mydata.points >= 100 and mydata.emeraldsword == 0 then
					mydata.emeraldsword = 1

					awardpoints(player, -100)
					local emeraldswordvalue = player:FindFirstChild("EmeraldSword")
					if emeraldswordvalue then
						emeraldswordvalue.Value = mydata.emeraldsword
					end
				end
			elseif tuple[2] == "Haste" then
				local mydata = playerdata[player.userId]
				print(mydata.hashaste)
				print(mydata.points)
				print(tuple[2])
				if mydata and mydata.points >= 250 and mydata.hashaste == 0 then
					mydata.hashaste = 1
					print(mydata.hashaste)
					print(mydata.points)
					print(tuple[2])

					awardpoints(player, -250)
					local hashastevalue = player:FindFirstChild("HasHaste")
					if hashastevalue then
						hashastevalue.Value = mydata.hashaste
					end
				end
			end
		end
	end
end)

Could you try changing the parameters passed to this?

event.OnServerEvent:Connect(function(player, ShopType, BoostType)

Then attempt to print what ShopType & BoostType is supposed to be

Huh it printed something. Here’s what it printed:

16:52:19.265 Haste - Client - LocalGuiScript:180 16:52:19.280 nil - Server - MainScript:260 16:52:19.280 327 - Server - MainScript:261 16:52:19.280 Haste - Server - MainScript:262

Oh something is from the LocalScript. My bad! :smile:

Plus you have any idea why Wren’s Treasure Chest #2 Didn’t unbox? I’m confused.

So Haste printed, but the shop type didn’t :thinking:

Very strange occurrence, you did print ShopType & BoostType correct? Try printing the player

I haven’t played any of the Metaverse games, I wouldn’t know

Try:

event.OnServerEvent:connect(function(player, ShopType, BoostType)
  print(ShopType, BoostType)

Yea but then it says: Syntax Error: Cannot use ‘. . .’ outside a vararg function

@JackscarIitt Oh and remember when that dude said “if you need help then post in #collaboration:recruitment”? Well i can’t pay anyone becuase i only have 3 R$.

A what now

Are you sure you still referenced the OnServerEvent as this?

event.OnServerEvent:Connect(function(player, ShopType, BoostType)

My assumption is that you’d need to remove the tuple variable