Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can anyone tell me why my script isnt workking or give me a new script its on superspeed?

local function CheckGamepass(player) local success, boughtGamepass = pcall(function() return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 19990375) end)

if success and boughtGamepass then
	if player.Character and player.Character:FindFirstChild("Humanoid") then
		player.Character.Humanoid.Walkspeed = 75
	else
		player.CharacterAdded:Wait()
		player.Character:WaitForChild("Humanoid")
		player.Character.Humanoid.Walkspeed = 75
	end
end

end game.Players.PlayerAdded:Connect(function(player) CheckGamepass(player) player.CharacterAdded:Connect(function(character) CheckGamepass(game.Players:GetPlayerFromCharacter(character)) end) end)

can anyone tell me why?

1 answer

✓ Accepted answer

Capitalization for variables/properties matters!

You did not have the proper capitalization for the lines containing player.Character.Humanoid.WalkSpeed = 75:

-- This is correct:
player.Character.Humanoid.WalkSpeed = 75

-- You had this:
player.Character.Humanoid.Walkspeed = 75

This is the full script with the modifications made:

local function CheckGamepass(player) 
	local success, boughtGamepass = pcall(function() 
		return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 19990375) 
	end)


	if success and boughtGamepass then
		if player.Character and player.Character:FindFirstChild("Humanoid") then
			player.Character.Humanoid.WalkSpeed = 75
		else
			player.CharacterAdded:Wait()
			player.Character:WaitForChild("Humanoid")
			player.Character.Humanoid.WalkSpeed = 75
		end
	end
end 

game.Players.PlayerAdded:Connect(function(player) 
	CheckGamepass(player) 
	player.CharacterAdded:Connect(function(character) 
		--CheckGamepass(game.Players:GetPlayerFromCharacter(character)) 
		-- ^^ Not sure why you are getting the player from it's character...
		CheckGamepass(player)
	end) 
end)

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.