I have a game pass implemented into my game (https://web.roblox.com/games/4959857494/Dash-RELEASE), which gives players infinite speed the power ups would normally give them. However, at the moment, once they get a power up, it does nothing (as they are already going at walkspeed 32), however then slows them back down to walkspeed 16, therefore making the game pass fairly pointless. Here is the link to the game pass so you can get the ID etc.

https://web.roblox.com/game-pass/9259330/Infinite-power-up-speed

I will give you the script to the power up, however please keep in mind this is a module script for most of my game as well. Lines 53 - 68 are power up, the rest is for the majority of my game.

local Dash = {}  

function  Dash.OnTouchedABlock(theBlock)
	local waitTime = 0.1
	wait(waitTime)
	theBlock.Transparency = 0.3
	wait(waitTime)
	theBlock.Transparency = 0.6
	wait(waitTime)
	theBlock.Transparency = 0.9
	wait(waitTime)
	theBlock.Transparency = 1
	theBlock.CanCollide = false
	wait(7)
	theBlock.Transparency = 0.9
	wait(waitTime)
	theBlock.Transparency = 0.6
	wait(waitTime)
	theBlock.Transparency = 0.3
	wait(waitTime)
	theBlock.Transparency = 0
	theBlock.CanCollide = true
end

function Dash.TouchToResetTA(toucher)
	print("Touched by " .. toucher.Parent:GetFullName())
   	if toucher.Parent:FindFirstChild("Humanoid") then
		local player = game.Players[toucher.Parent.Name]
		print(player.leaderstats["Time Alive"].Value)
		player.leaderstats["Time Alive"].Value = 0
	end
end

function Dash.WireUpDoorway(doorway)
	doorway.Touched:connect(Dash.TouchToResetTA)
end

function Dash.WireUpPlate(plate)
	plate.Touched:connect(function()
		Dash.OnTouchedABlock(plate)
	end)
	
	local powerup = Instance.new("Part", workspace)
	powerup.Transparency = 1
	powerup.Name = "powerup"
	powerup.Position = plate.Position + Vector3.new(0,3.5,0)
	powerup.Size = Vector3.new(2,2,2)
	powerup.Anchored = true
	powerup.Color = Color3.fromRGB(255,0,0)
	powerup.CanCollide = false
	

	local function TouchedPowerup(toucher)
		if powerup.Transparency ~= 1 then
			powerup.Transparency = 1
			if toucher.Parent:FindFirstChild("Humanoid") then
				local player = game.Players[toucher.Parent.Name]
				print(player.Name .. " got a powerup!")
				--/Speed up!
				player.Character:WaitForChild("Humanoid").WalkSpeed = 32
				wait(10)
				--/Slow down!
				player.Character:WaitForChild("Humanoid").WalkSpeed = 16
			end
		end
	end
	
	powerup.Touched:connect(TouchedPowerup)
	
	while true do
		wait(1)
		if math.random(1, 3780) == 1 then
			powerup.Transparency = 0.3
		end
	end
end

return Dash

And here is the game pass script:

local id = 9259330

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
 if purchased and ido == id then
  plr.Character.Humanoid.WalkSpeed = 32
 end
end)
 
game.Players.PlayerAdded:Connect(function(plr)
 plr.CharacterAdded:connect(function(char)
  if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
   char.Humanoid.WalkSpeed = 32
  end
 end)
end)

Hope someone can help!

2 comments

0

In the purchase script, make sure to add "repeat wait() until purchased and ido == id", And below plr.Character.Humanoid.WalkSpeed = 32.

0

Ok, thank you. But do you have an answer?